|
5 | 5 | {-# LANGUAGE FlexibleContexts #-} |
6 | 6 | {-# LANGUAGE LambdaCase #-} |
7 | 7 | {-# LANGUAGE OverloadedStrings #-} |
| 8 | +{-# LANGUAGE RecordWildCards #-} |
8 | 9 | {-# LANGUAGE StandaloneDeriving #-} |
9 | 10 | {-# LANGUAGE TypeApplications #-} |
10 | 11 | {-# LANGUAGE TypeFamilies #-} |
@@ -68,12 +69,9 @@ import Cardano.Ledger.BaseTypes ( |
68 | 69 | strictMaybeToMaybe, |
69 | 70 | ) |
70 | 71 | import Cardano.Ledger.Binary ( |
71 | | - CBORGroup (..), |
72 | 72 | DecCBOR (..), |
73 | | - DecCBORGroup (..), |
74 | 73 | DecShareCBOR (..), |
75 | 74 | EncCBOR (..), |
76 | | - EncCBORGroup (..), |
77 | 75 | decodeNullMaybe, |
78 | 76 | decodeRecordNamed, |
79 | 77 | decodeRecordSum, |
@@ -381,8 +379,6 @@ data PoolParams = PoolParams |
381 | 379 | , ppMetadata :: !(StrictMaybe PoolMetadata) |
382 | 380 | } |
383 | 381 | deriving (Show, Generic, Eq, Ord) |
384 | | - deriving (EncCBOR) via CBORGroup PoolParams |
385 | | - deriving (DecCBOR) via CBORGroup PoolParams |
386 | 382 |
|
387 | 383 | ppVrfL :: Lens' PoolParams (VRFVerKeyHash 'StakePoolVRF) |
388 | 384 | ppVrfL = lens ppVrf (\pp u -> pp {ppVrf = u}) |
@@ -452,40 +448,44 @@ data SizeOfPoolRelays = SizeOfPoolRelays |
452 | 448 | instance EncCBOR SizeOfPoolRelays where |
453 | 449 | encCBOR = error "The `SizeOfPoolRelays` type cannot be encoded!" |
454 | 450 |
|
455 | | -instance EncCBORGroup PoolParams where |
456 | | - encCBORGroup poolParams = |
457 | | - encCBOR (ppId poolParams) |
458 | | - <> encCBOR (ppVrf poolParams) |
459 | | - <> encCBOR (ppPledge poolParams) |
460 | | - <> encCBOR (ppCost poolParams) |
461 | | - <> encCBOR (ppMargin poolParams) |
462 | | - <> encCBOR (ppRewardAccount poolParams) |
463 | | - <> encCBOR (ppOwners poolParams) |
464 | | - <> encCBOR (ppRelays poolParams) |
465 | | - <> encodeNullMaybe encCBOR (strictMaybeToMaybe (ppMetadata poolParams)) |
466 | | - listLen _ = 9 |
467 | | - listLenBound _ = 9 |
468 | | - |
469 | | -instance DecCBORGroup PoolParams where |
470 | | - decCBORGroup = do |
471 | | - hk <- decCBOR |
472 | | - vrf <- decCBOR |
473 | | - pledge <- decCBOR |
474 | | - cost <- decCBOR |
475 | | - margin <- decCBOR |
476 | | - ra <- decCBOR |
477 | | - owners <- decCBOR |
478 | | - relays <- decCBOR |
479 | | - md <- decodeNullMaybe decCBOR |
480 | | - pure $ |
481 | | - PoolParams |
482 | | - { ppId = hk |
483 | | - , ppVrf = vrf |
484 | | - , ppPledge = pledge |
485 | | - , ppCost = cost |
486 | | - , ppMargin = margin |
487 | | - , ppRewardAccount = ra |
488 | | - , ppOwners = owners |
489 | | - , ppRelays = relays |
490 | | - , ppMetadata = maybeToStrictMaybe md |
491 | | - } |
| 451 | +instance EncCBOR PoolParams where |
| 452 | + encCBOR PoolParams {..} = |
| 453 | + encodeListLen 9 |
| 454 | + <> encCBOR ppId |
| 455 | + <> encCBOR ppVrf |
| 456 | + <> encCBOR ppPledge |
| 457 | + <> encCBOR ppCost |
| 458 | + <> encCBOR ppMargin |
| 459 | + <> encCBOR ppRewardAccount |
| 460 | + <> encCBOR ppOwners |
| 461 | + <> encCBOR ppRelays |
| 462 | + <> encodeNullMaybe encCBOR (strictMaybeToMaybe ppMetadata) |
| 463 | + |
| 464 | +instance DecCBOR PoolParams where |
| 465 | + decCBOR = |
| 466 | + decodeRecordNamed |
| 467 | + "CBORGroup" |
| 468 | + (const 9) |
| 469 | + ( do |
| 470 | + hk <- decCBOR |
| 471 | + vrf <- decCBOR |
| 472 | + pledge <- decCBOR |
| 473 | + cost <- decCBOR |
| 474 | + margin <- decCBOR |
| 475 | + ra <- decCBOR |
| 476 | + owners <- decCBOR |
| 477 | + relays <- decCBOR |
| 478 | + md <- decodeNullMaybe decCBOR |
| 479 | + pure $ |
| 480 | + PoolParams |
| 481 | + { ppId = hk |
| 482 | + , ppVrf = vrf |
| 483 | + , ppPledge = pledge |
| 484 | + , ppCost = cost |
| 485 | + , ppMargin = margin |
| 486 | + , ppRewardAccount = ra |
| 487 | + , ppOwners = owners |
| 488 | + , ppRelays = relays |
| 489 | + , ppMetadata = maybeToStrictMaybe md |
| 490 | + } |
| 491 | + ) |
0 commit comments