{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Test.Cardano.Ledger.Conway.Binary.RoundTrip (
roundTripConwayCommonSpec,
roundTripConwayEraTypesSpec,
) where
import Cardano.Ledger.BaseTypes (StrictMaybe)
import qualified Cardano.Ledger.Binary as Binary
import Cardano.Ledger.Binary.Plain (Tokens (TkBreak, TkListBegin, TkListLen))
import qualified Cardano.Ledger.Binary.Plain as Plain
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Conway.Governance
import Cardano.Ledger.Conway.State
import Cardano.Ledger.Core
import Cardano.Ledger.Plutus (CostModels)
import Data.Default (def)
import qualified Data.Foldable as F
import Data.List (isInfixOf)
import Lens.Micro
import Test.Cardano.Ledger.Alonzo.Binary.RoundTrip (roundTripAlonzoCommonSpec)
import Test.Cardano.Ledger.Binary.Plain.Golden (Enc (..))
import Test.Cardano.Ledger.Common
import Test.Cardano.Ledger.Conway.Arbitrary (genGovActionState)
import Test.Cardano.Ledger.Conway.Era (ConwayEraTest)
import Test.Cardano.Ledger.Core.Binary.RoundTrip
roundTripConwayCommonSpec :: forall era. ConwayEraTest era => Spec
roundTripConwayCommonSpec :: forall era. ConwayEraTest era => Spec
roundTripConwayCommonSpec = do
forall era.
(Arbitrary (PParams era), Arbitrary (PParamsUpdate era),
Arbitrary (PParamsHKD StrictMaybe era),
Arbitrary (InstantStake era), EraPParams era, EraStake era,
ConwayEraAccounts era) =>
Spec
roundTripConwayEraTypesSpec @era
forall era. AlonzoEraTest era => Spec
roundTripAlonzoCommonSpec @era
roundTripConwayEraTypesSpec ::
forall era.
( Arbitrary (PParams era)
, Arbitrary (PParamsUpdate era)
, Arbitrary (PParamsHKD StrictMaybe era)
, Arbitrary (InstantStake era)
, EraPParams era
, EraStake era
, ConwayEraAccounts era
) =>
Spec
roundTripConwayEraTypesSpec :: forall era.
(Arbitrary (PParams era), Arbitrary (PParamsUpdate era),
Arbitrary (PParamsHKD StrictMaybe era),
Arbitrary (InstantStake era), EraPParams era, EraStake era,
ConwayEraAccounts era) =>
Spec
roundTripConwayEraTypesSpec = do
String -> Spec -> Spec
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe (forall era. Era era => String
eraName @era String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" Transaction Types") (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$ do
forall era (t :: * -> *).
(Era era, Show (t era), Eq (t era), EncCBOR (t era),
DecCBOR (t era), Arbitrary (t era), HasCallStack) =>
Spec
roundTripEraTypeSpec @era @GovAction
forall era (t :: * -> *).
(Era era, Show (t era), Eq (t era), EncCBOR (t era),
DecCBOR (t era), Arbitrary (t era), HasCallStack) =>
Spec
roundTripEraTypeSpec @era @VotingProcedure
forall era (t :: * -> *).
(Era era, Show (t era), Eq (t era), EncCBOR (t era),
DecCBOR (t era), Arbitrary (t era), HasCallStack) =>
Spec
roundTripEraTypeSpec @era @VotingProcedures
forall era (t :: * -> *).
(Era era, Show (t era), Eq (t era), EncCBOR (t era),
DecCBOR (t era), Arbitrary (t era), HasCallStack) =>
Spec
roundTripEraTypeSpec @era @ProposalProcedure
forall era (t :: * -> *).
(Era era, Show (t era), Eq (t era), EncCBOR (t era),
DecCBOR (t era), Arbitrary (t era), HasCallStack) =>
Spec
roundTripEraTypeSpec @era @Constitution
String -> (CostModels -> Expectation) -> Spec
forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop String
"CostModels" ((CostModels -> Expectation) -> Spec)
-> (CostModels -> Expectation) -> Spec
forall a b. (a -> b) -> a -> b
$ forall era t.
(Era era, Show t, Eq t, EncCBOR t, DecCBOR t, HasCallStack) =>
t -> Expectation
roundTripEraExpectation @era @CostModels
String -> Spec -> Spec
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe (forall era. Era era => String
eraName @era String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" State Types") (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$ do
forall era (t :: * -> *).
(Era era, Typeable t, Show (t era), Eq (t era), EncCBOR (t era),
DecShareCBOR (t era), Arbitrary (t era), HasCallStack) =>
Spec
roundTripShareEraTypeSpec @era @EnactState
forall era (t :: * -> *).
(Era era, Typeable t, Show (t era), Eq (t era), EncCBOR (t era),
DecShareCBOR (t era), Arbitrary (t era), HasCallStack) =>
Spec
roundTripShareEraTypeSpec @era @GovActionState
forall era (t :: * -> *).
(Era era, Typeable t, Show (t era), Eq (t era), EncCBOR (t era),
DecShareCBOR (t era), Arbitrary (t era), HasCallStack) =>
Spec
roundTripShareEraTypeSpec @era @Proposals
forall era.
(EraPParams era, ConwayEraAccounts era, EraStake era) =>
Spec
proposalsDecodingSpec @era
forall era (t :: * -> *).
(Era era, Typeable t, Show (t era), Eq (t era), EncCBOR (t era),
DecShareCBOR (t era), Arbitrary (t era), HasCallStack) =>
Spec
roundTripShareEraTypeSpec @era @DRepPulsingState
forall era (t :: * -> *).
(Era era, Typeable t, Show (t era), Eq (t era), EncCBOR (t era),
DecShareCBOR (t era), Arbitrary (t era), HasCallStack) =>
Spec
roundTripShareEraTypeSpec @era @PulsingSnapshot
forall era (t :: * -> *).
(Era era, Typeable t, Show (t era), Eq (t era), EncCBOR (t era),
DecShareCBOR (t era), Arbitrary (t era), HasCallStack) =>
Spec
roundTripShareEraTypeSpec @era @RatifyState
forall era (t :: * -> *).
(Era era, Typeable t, Show (t era), Eq (t era), EncCBOR (t era),
DecShareCBOR (t era), Arbitrary (t era), HasCallStack) =>
Spec
roundTripShareEraTypeSpec @era @VState
proposalsDecodingSpec ::
forall era.
(EraPParams era, ConwayEraAccounts era, EraStake era) =>
Spec
proposalsDecodingSpec :: forall era.
(EraPParams era, ConwayEraAccounts era, EraStake era) =>
Spec
proposalsDecodingSpec =
String -> Spec -> Spec
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
"Proposals decoding" (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$
[Version] -> (Version -> Spec) -> Spec
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [forall era. Era era => Version
eraProtVerLow @era .. forall era. Era era => Version
eraProtVerHigh @era] ((Version -> Spec) -> Spec) -> (Version -> Spec) -> Spec
forall a b. (a -> b) -> a -> b
$ \Version
version ->
String -> Spec -> Spec
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe (Version -> String
forall a. Show a => a -> String
show Version
version) (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$
[(String, [Enc] -> Enc)]
-> ((String, [Enc] -> Enc) -> Spec) -> Spec
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [(String, [Enc] -> Enc)]
arrayForms (((String, [Enc] -> Enc) -> Spec) -> Spec)
-> ((String, [Enc] -> Enc) -> Spec) -> Spec
forall a b. (a -> b) -> a -> b
$ \(String
arrayName, [Enc] -> Enc
arrayEncoding) ->
String -> Spec -> Spec
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
arrayName (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$
[(String, Enc -> Either DecoderError (Proposals era))]
-> ((String, Enc -> Either DecoderError (Proposals era)) -> Spec)
-> Spec
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ (Version -> [(String, Enc -> Either DecoderError (Proposals era))]
decoders Version
version) (((String, Enc -> Either DecoderError (Proposals era)) -> Spec)
-> Spec)
-> ((String, Enc -> Either DecoderError (Proposals era)) -> Spec)
-> Spec
forall a b. (a -> b) -> a -> b
$ \(String
decoderName, Enc -> Either DecoderError (Proposals era)
decode) ->
String -> Spec -> Spec
forall a. HasCallStack => String -> SpecWith a -> SpecWith a
describe String
decoderName (Spec -> Spec) -> Spec -> Spec
forall a b. (a -> b) -> a -> b
$ do
[(String,
GovActionState era -> GovActionState era -> [GovActionState era])]
-> ((String,
GovActionState era -> GovActionState era -> [GovActionState era])
-> Spec)
-> Spec
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_
[ (String
"Identical adjacent", \GovActionState era
a GovActionState era
b -> [GovActionState era
a, GovActionState era
a, GovActionState era
b])
, (String
"Identical separated", \GovActionState era
a GovActionState era
b -> [GovActionState era
a, GovActionState era
b, GovActionState era
a])
, (String
"Conflicting adjacent", \GovActionState era
a GovActionState era
b -> [GovActionState era
a, GovActionState era
a GovActionState era
-> (GovActionState era -> GovActionState era) -> GovActionState era
forall a b. a -> (a -> b) -> b
& (Coin -> Identity Coin)
-> GovActionState era -> Identity (GovActionState era)
forall era (f :: * -> *).
Functor f =>
(Coin -> f Coin) -> GovActionState era -> f (GovActionState era)
gasDepositL ((Coin -> Identity Coin)
-> GovActionState era -> Identity (GovActionState era))
-> Coin -> GovActionState era -> GovActionState era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Integer -> Coin
Coin Integer
2, GovActionState era
b])
, (String
"Conflicting separated", \GovActionState era
a GovActionState era
b -> [GovActionState era
a, GovActionState era
b, GovActionState era
a GovActionState era
-> (GovActionState era -> GovActionState era) -> GovActionState era
forall a b. a -> (a -> b) -> b
& (Coin -> Identity Coin)
-> GovActionState era -> Identity (GovActionState era)
forall era (f :: * -> *).
Functor f =>
(Coin -> f Coin) -> GovActionState era -> f (GovActionState era)
gasDepositL ((Coin -> Identity Coin)
-> GovActionState era -> Identity (GovActionState era))
-> Coin -> GovActionState era -> GovActionState era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Integer -> Coin
Coin Integer
2])
]
(((String,
GovActionState era -> GovActionState era -> [GovActionState era])
-> Spec)
-> Spec)
-> ((String,
GovActionState era -> GovActionState era -> [GovActionState era])
-> Spec)
-> Spec
forall a b. (a -> b) -> a -> b
$ \(String
name, GovActionState era -> GovActionState era -> [GovActionState era]
duplicateActions) ->
String -> Property -> Spec
forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop (String
name String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" duplicate IDs are rejected") (Property -> Spec) -> Property -> Spec
forall a b. (a -> b) -> a -> b
$
Gen (GovActionState era)
-> (GovActionState era -> Expectation) -> Property
forall a prop.
(Show a, Testable prop) =>
Gen a -> (a -> prop) -> Property
forAll Gen (GovActionState era)
actionGen ((GovActionState era -> Expectation) -> Property)
-> (GovActionState era -> Expectation) -> Property
forall a b. (a -> b) -> a -> b
$ \GovActionState era
gas -> do
let actions :: [GovActionState era]
actions = GovActionState era -> GovActionState era -> [GovActionState era]
duplicateActions (Word16 -> GovActionState era -> GovActionState era
forall {era}. Word16 -> GovActionState era -> GovActionState era
withIndex Word16
0 GovActionState era
gas) (Word16 -> GovActionState era -> GovActionState era
forall {era}. Word16 -> GovActionState era -> GovActionState era
withIndex Word16
1 GovActionState era
gas)
err <- Either DecoderError (Proposals era) -> IO DecoderError
forall b a. (HasCallStack, Show b) => Either a b -> IO a
expectLeft (Either DecoderError (Proposals era) -> IO DecoderError)
-> Either DecoderError (Proposals era) -> IO DecoderError
forall a b. (a -> b) -> a -> b
$ Enc -> Either DecoderError (Proposals era)
decode (Enc -> Either DecoderError (Proposals era))
-> Enc -> Either DecoderError (Proposals era)
forall a b. (a -> b) -> a -> b
$ Version -> ([Enc] -> Enc) -> [GovActionState era] -> Enc
forall {f :: * -> *} {a}.
(Functor f, EncCBOR a) =>
Version -> (f Enc -> Enc) -> f a -> Enc
proposalsEnc Version
version [Enc] -> Enc
arrayEncoding [GovActionState era]
actions
show err
`shouldSatisfy` isInfixOf
"Final number of elements: 2 does not match the total count that was decoded: 3"
[(String, [Word16])] -> ((String, [Word16]) -> Spec) -> Spec
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [(String
"Empty", []), (String
"Insertion order", [Word16
2, Word16
0, Word16
1])] (((String, [Word16]) -> Spec) -> Spec)
-> ((String, [Word16]) -> Spec) -> Spec
forall a b. (a -> b) -> a -> b
$ \(String
name, [Word16]
indices) ->
String -> Property -> Spec
forall prop.
(HasCallStack, Testable prop) =>
String -> prop -> Spec
prop (String
name String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
" proposals decode unchanged") (Property -> Spec) -> Property -> Spec
forall a b. (a -> b) -> a -> b
$
Gen (GovActionState era)
-> (GovActionState era -> Expectation) -> Property
forall a prop.
(Show a, Testable prop) =>
Gen a -> (a -> prop) -> Property
forAll Gen (GovActionState era)
actionGen ((GovActionState era -> Expectation) -> Property)
-> (GovActionState era -> Expectation) -> Property
forall a b. (a -> b) -> a -> b
$ \GovActionState era
gas -> do
let actions :: [GovActionState era]
actions = (\Word16
n -> Word16 -> GovActionState era -> GovActionState era
forall {era}. Word16 -> GovActionState era -> GovActionState era
withIndex Word16
n GovActionState era
gas) (Word16 -> GovActionState era) -> [Word16] -> [GovActionState era]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Word16]
indices
actual <- Either DecoderError (Proposals era) -> IO (Proposals era)
forall a b. (HasCallStack, Show a) => Either a b -> IO b
expectRight (Either DecoderError (Proposals era) -> IO (Proposals era))
-> Either DecoderError (Proposals era) -> IO (Proposals era)
forall a b. (a -> b) -> a -> b
$ Enc -> Either DecoderError (Proposals era)
decode (Enc -> Either DecoderError (Proposals era))
-> Enc -> Either DecoderError (Proposals era)
forall a b. (a -> b) -> a -> b
$ Version -> ([Enc] -> Enc) -> [GovActionState era] -> Enc
forall {f :: * -> *} {a}.
(Functor f, EncCBOR a) =>
Version -> (f Enc -> Enc) -> f a -> Enc
proposalsEnc Version
version [Enc] -> Enc
arrayEncoding [GovActionState era]
actions
F.toList (proposalsActions actual) `shouldBe` actions
where
actionGen :: Gen (GovActionState era)
actionGen =
((Coin -> Identity Coin)
-> GovActionState era -> Identity (GovActionState era)
forall era (f :: * -> *).
Functor f =>
(Coin -> f Coin) -> GovActionState era -> f (GovActionState era)
gasDepositL ((Coin -> Identity Coin)
-> GovActionState era -> Identity (GovActionState era))
-> Coin -> GovActionState era -> GovActionState era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Integer -> Coin
Coin Integer
1) (GovActionState era -> GovActionState era)
-> Gen (GovActionState era) -> Gen (GovActionState era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Int -> Gen (GovActionState era) -> Gen (GovActionState era)
forall a. HasCallStack => Int -> Gen a -> Gen a
resize Int
3 (forall era. GovAction era -> Gen (GovActionState era)
genGovActionState @era GovAction era
forall era. GovAction era
InfoAction)
withIndex :: Word16 -> GovActionState era -> GovActionState era
withIndex Word16
n GovActionState era
gas =
GovActionState era
gas GovActionState era
-> (GovActionState era -> GovActionState era) -> GovActionState era
forall a b. a -> (a -> b) -> b
& (GovActionId -> Identity GovActionId)
-> GovActionState era -> Identity (GovActionState era)
forall era (f :: * -> *).
Functor f =>
(GovActionId -> f GovActionId)
-> GovActionState era -> f (GovActionState era)
gasIdL ((GovActionId -> Identity GovActionId)
-> GovActionState era -> Identity (GovActionState era))
-> (GovActionId -> GovActionId)
-> GovActionState era
-> GovActionState era
forall s t a b. ASetter s t a b -> (a -> b) -> s -> t
%~ (\GovActionId
gai -> GovActionId
gai {gaidGovActionIx = GovActionIx n})
arrayForms :: [(String, [Enc] -> Enc)]
arrayForms =
[ (String
"Definite", \[Enc]
values -> [Enc] -> Enc
Em [(Tokens -> Tokens) -> Enc
forall a. ToCBOR a => a -> Enc
E ((Tokens -> Tokens) -> Enc) -> (Tokens -> Tokens) -> Enc
forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkListLen (Word -> Tokens -> Tokens) -> Word -> Tokens -> Tokens
forall a b. (a -> b) -> a -> b
$ Int -> Word
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Word) -> Int -> Word
forall a b. (a -> b) -> a -> b
$ [Enc] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Enc]
values, [Enc] -> Enc
Em [Enc]
values])
, (String
"Indefinite", \[Enc]
values -> [Enc] -> Enc
Em [(Tokens -> Tokens) -> Enc
forall a. ToCBOR a => a -> Enc
E Tokens -> Tokens
TkListBegin, [Enc] -> Enc
Em [Enc]
values, (Tokens -> Tokens) -> Enc
forall a. ToCBOR a => a -> Enc
E Tokens -> Tokens
TkBreak])
]
proposalsEnc :: Version -> (f Enc -> Enc) -> f a -> Enc
proposalsEnc Version
version f Enc -> Enc
arrayEncoding f a
actions =
[Enc] -> Enc
Em
[ (Tokens -> Tokens) -> Enc
forall a. ToCBOR a => a -> Enc
E ((Tokens -> Tokens) -> Enc) -> (Tokens -> Tokens) -> Enc
forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkListLen Word
2
, Version -> GovRelation StrictMaybe -> Enc
forall a. EncCBOR a => Version -> a -> Enc
Ev Version
version (GovRelation StrictMaybe
forall a. Default a => a
def :: GovRelation StrictMaybe)
, f Enc -> Enc
arrayEncoding (f Enc -> Enc) -> f Enc -> Enc
forall a b. (a -> b) -> a -> b
$ Version -> a -> Enc
forall a. EncCBOR a => Version -> a -> Enc
Ev Version
version (a -> Enc) -> f a -> f Enc
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f a
actions
]
govStateEnc :: Version -> Enc -> Enc
govStateEnc Version
version Enc
proposals =
let state :: ConwayGovState era
state = ConwayGovState era
forall a. Default a => a
def :: ConwayGovState era
in [Enc] -> Enc
Em
[ (Tokens -> Tokens) -> Enc
forall a. ToCBOR a => a -> Enc
E ((Tokens -> Tokens) -> Enc) -> (Tokens -> Tokens) -> Enc
forall a b. (a -> b) -> a -> b
$ Word -> Tokens -> Tokens
TkListLen Word
7
, Enc
proposals
, Version -> StrictMaybe (Committee era) -> Enc
forall a. EncCBOR a => Version -> a -> Enc
Ev Version
version (StrictMaybe (Committee era) -> Enc)
-> StrictMaybe (Committee era) -> Enc
forall a b. (a -> b) -> a -> b
$ ConwayGovState era -> StrictMaybe (Committee era)
forall era. ConwayGovState era -> StrictMaybe (Committee era)
cgsCommittee ConwayGovState era
state
, Version -> Constitution era -> Enc
forall a. EncCBOR a => Version -> a -> Enc
Ev Version
version (Constitution era -> Enc) -> Constitution era -> Enc
forall a b. (a -> b) -> a -> b
$ ConwayGovState era -> Constitution era
forall era. ConwayGovState era -> Constitution era
cgsConstitution ConwayGovState era
state
, Version -> PParams era -> Enc
forall a. EncCBOR a => Version -> a -> Enc
Ev Version
version (PParams era -> Enc) -> PParams era -> Enc
forall a b. (a -> b) -> a -> b
$ ConwayGovState era -> PParams era
forall era. ConwayGovState era -> PParams era
cgsCurPParams ConwayGovState era
state
, Version -> PParams era -> Enc
forall a. EncCBOR a => Version -> a -> Enc
Ev Version
version (PParams era -> Enc) -> PParams era -> Enc
forall a b. (a -> b) -> a -> b
$ ConwayGovState era -> PParams era
forall era. ConwayGovState era -> PParams era
cgsPrevPParams ConwayGovState era
state
, Version -> FuturePParams era -> Enc
forall a. EncCBOR a => Version -> a -> Enc
Ev Version
version (FuturePParams era -> Enc) -> FuturePParams era -> Enc
forall a b. (a -> b) -> a -> b
$ ConwayGovState era -> FuturePParams era
forall era. ConwayGovState era -> FuturePParams era
cgsFuturePParams ConwayGovState era
state
, Version -> DRepPulsingState era -> Enc
forall a. EncCBOR a => Version -> a -> Enc
Ev Version
version (DRepPulsingState era -> Enc) -> DRepPulsingState era -> Enc
forall a b. (a -> b) -> a -> b
$ ConwayGovState era -> DRepPulsingState era
forall era. ConwayGovState era -> DRepPulsingState era
cgsDRepPulsingState ConwayGovState era
state
]
decoders ::
Binary.Version ->
[(String, Enc -> Either Binary.DecoderError (Proposals era))]
decoders :: Version -> [(String, Enc -> Either DecoderError (Proposals era))]
decoders Version
version =
[ (String
"Ordinary", Version -> ByteString -> Either DecoderError (Proposals era)
forall a.
DecCBOR a =>
Version -> ByteString -> Either DecoderError a
Binary.decodeFull Version
version (ByteString -> Either DecoderError (Proposals era))
-> (Enc -> ByteString)
-> Enc
-> Either DecoderError (Proposals era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Enc -> ByteString
forall a. ToCBOR a => a -> ByteString
Plain.serialize)
,
( String
"Shared"
, Version
-> Text
-> (forall s. Decoder s (Proposals era))
-> ByteString
-> Either DecoderError (Proposals era)
forall a.
Version
-> Text
-> (forall s. Decoder s a)
-> ByteString
-> Either DecoderError a
Binary.decodeFullDecoder Version
version Text
"Proposals regression" Decoder s (Proposals era)
forall s. Decoder s (Proposals era)
forall a s. DecShareCBOR a => Decoder s a
Binary.decNoShareCBOR (ByteString -> Either DecoderError (Proposals era))
-> (Enc -> ByteString)
-> Enc
-> Either DecoderError (Proposals era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Enc -> ByteString
forall a. ToCBOR a => a -> ByteString
Plain.serialize
)
,
( String
"Governance state"
, (ConwayGovState era -> Proposals era)
-> Either DecoderError (ConwayGovState era)
-> Either DecoderError (Proposals era)
forall a b.
(a -> b) -> Either DecoderError a -> Either DecoderError b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ConwayGovState era -> Proposals era
forall era. ConwayGovState era -> Proposals era
cgsProposals (Either DecoderError (ConwayGovState era)
-> Either DecoderError (Proposals era))
-> (Enc -> Either DecoderError (ConwayGovState era))
-> Enc
-> Either DecoderError (Proposals era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Version -> ByteString -> Either DecoderError (ConwayGovState era)
forall a.
DecCBOR a =>
Version -> ByteString -> Either DecoderError a
Binary.decodeFull Version
version (ByteString -> Either DecoderError (ConwayGovState era))
-> (Enc -> ByteString)
-> Enc
-> Either DecoderError (ConwayGovState era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Enc -> ByteString
forall a. ToCBOR a => a -> ByteString
Plain.serialize (Enc -> ByteString) -> (Enc -> Enc) -> Enc -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Version -> Enc -> Enc
govStateEnc Version
version
)
]