From e59a6010c932ea6bf2171ad14ba579adb5740a91 Mon Sep 17 00:00:00 2001 From: Javier Sagredo Date: Wed, 29 Jan 2025 11:22:17 +0100 Subject: [PATCH] Add CBOR instances for DefaultVote --- eras/conway/impl/CHANGELOG.md | 1 + .../src/Cardano/Ledger/Conway/Governance.hs | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/eras/conway/impl/CHANGELOG.md b/eras/conway/impl/CHANGELOG.md index c486e983407..97dc83f10f6 100644 --- a/eras/conway/impl/CHANGELOG.md +++ b/eras/conway/impl/CHANGELOG.md @@ -2,6 +2,7 @@ ## 1.19.0.0 +* Added `ToCBOR` and `FromCBOR` instances for `DefaultVote`. * Made the fields of predicate failures and environments lazy * Add `MemPack` instance for `PlutusScript ConwayEra` * Deprecate `Conway` type synonym diff --git a/eras/conway/impl/src/Cardano/Ledger/Conway/Governance.hs b/eras/conway/impl/src/Cardano/Ledger/Conway/Governance.hs index 605c804ba47..ef3069a507f 100644 --- a/eras/conway/impl/src/Cardano/Ledger/Conway/Governance.hs +++ b/eras/conway/impl/src/Cardano/Ledger/Conway/Governance.hs @@ -202,6 +202,10 @@ import Cardano.Ledger.Binary.Coders ( (!>), ( pure DefaultNo + 1 -> pure DefaultAbstain + 2 -> pure DefaultNoConfidence + _ -> fail $ "Invalid DefaultVote tag " ++ show tag + +instance ToCBOR DefaultVote where + toCBOR DefaultNo = encodeWord8 0 + toCBOR DefaultAbstain = encodeWord8 1 + toCBOR DefaultNoConfidence = encodeWord8 2 + +instance EncCBOR DefaultVote +instance DecCBOR DefaultVote + defaultStakePoolVote :: -- | Specify the key hash of the pool whose default vote should be returned. KeyHash 'StakePool ->