Skip to content

Commit

Permalink
Add CBOR instances for DefaultVote
Browse files Browse the repository at this point in the history
  • Loading branch information
jasagredo committed Jan 29, 2025
1 parent 4b2721c commit 5093b24
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions eras/conway/impl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions eras/conway/impl/src/Cardano/Ledger/Conway/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ import Cardano.Ledger.Binary.Coders (
(!>),
(<!),
)
import Cardano.Ledger.Binary.Plain (
decodeWord8,
encodeWord8,
)
import Cardano.Ledger.CertState (
CommitteeAuthorization (..),
Obligations (..),
Expand Down Expand Up @@ -541,6 +545,20 @@ data DefaultVote
DefaultNoConfidence
deriving (Eq, Show)

instance FromCBOR DefaultVote where
fromCBOR = do
tag <- decodeWord8
pure $ case tag of
0 -> DefaultNo
1 -> DefaultAbstain
2 -> DefaultNoConfidence
_ -> error $ "Invalid DefaultVote tag " ++ show tag

instance ToCBOR DefaultVote where
toCBOR DefaultNo = encodeWord8 0
toCBOR DefaultAbstain = encodeWord8 1
toCBOR DefaultNoConfidence = encodeWord8 2

defaultStakePoolVote ::
-- | Specify the key hash of the pool whose default vote should be returned.
KeyHash 'StakePool ->
Expand Down

0 comments on commit 5093b24

Please sign in to comment.