|
8 | 8 | {-# LANGUAGE GADTs #-} |
9 | 9 | {-# LANGUAGE GeneralizedNewtypeDeriving #-} |
10 | 10 | {-# LANGUAGE InstanceSigs #-} |
| 11 | +{-# LANGUAGE LambdaCase #-} |
11 | 12 | {-# LANGUAGE MultiParamTypeClasses #-} |
12 | 13 | {-# LANGUAGE NamedFieldPuns #-} |
13 | 14 | {-# LANGUAGE OverloadedStrings #-} |
@@ -97,6 +98,7 @@ import Cardano.Ledger.Binary.Coders ( |
97 | 98 | decode, |
98 | 99 | encode, |
99 | 100 | field, |
| 101 | + invalidField, |
100 | 102 | (!>), |
101 | 103 | ) |
102 | 104 | import Cardano.Ledger.Coin (Coin (..)) |
@@ -663,31 +665,32 @@ instance Era era => EncCBOR (AlonzoPParams StrictMaybe era) where |
663 | 665 | encCBOR ppup = encode (encodePParamsUpdate ppup) |
664 | 666 |
|
665 | 667 | updateField :: Word -> Field (AlonzoPParams StrictMaybe era) |
666 | | -updateField 0 = field (\x up -> up {appMinFeeA = SJust x}) From |
667 | | -updateField 1 = field (\x up -> up {appMinFeeB = SJust x}) From |
668 | | -updateField 2 = field (\x up -> up {appMaxBBSize = SJust x}) From |
669 | | -updateField 3 = field (\x up -> up {appMaxTxSize = SJust x}) From |
670 | | -updateField 4 = field (\x up -> up {appMaxBHSize = SJust x}) From |
671 | | -updateField 5 = field (\x up -> up {appKeyDeposit = SJust x}) From |
672 | | -updateField 6 = field (\x up -> up {appPoolDeposit = SJust x}) From |
673 | | -updateField 7 = field (\x up -> up {appEMax = SJust x}) From |
674 | | -updateField 8 = field (\x up -> up {appNOpt = SJust x}) From |
675 | | -updateField 9 = field (\x up -> up {appA0 = SJust x}) From |
676 | | -updateField 10 = field (\x up -> up {appRho = SJust x}) From |
677 | | -updateField 11 = field (\x up -> up {appTau = SJust x}) From |
678 | | -updateField 12 = field (\x up -> up {appD = SJust x}) From |
679 | | -updateField 13 = field (\x up -> up {appExtraEntropy = SJust x}) From |
680 | | -updateField 14 = field (\x up -> up {appProtocolVersion = SJust x}) From |
681 | | -updateField 16 = field (\x up -> up {appMinPoolCost = SJust x}) From |
682 | | -updateField 17 = field (\x up -> up {appCoinsPerUTxOWord = SJust x}) From |
683 | | -updateField 18 = field (\x up -> up {appCostModels = SJust x}) From |
684 | | -updateField 19 = field (\x up -> up {appPrices = SJust x}) From |
685 | | -updateField 20 = field (\x up -> up {appMaxTxExUnits = SJust x}) From |
686 | | -updateField 21 = field (\x up -> up {appMaxBlockExUnits = SJust x}) From |
687 | | -updateField 22 = field (\x up -> up {appMaxValSize = SJust x}) From |
688 | | -updateField 23 = field (\x up -> up {appCollateralPercentage = SJust x}) From |
689 | | -updateField 24 = field (\x up -> up {appMaxCollateralInputs = SJust x}) From |
690 | | -updateField k = field (\_x up -> up) (Invalid k) |
| 668 | +updateField = \case |
| 669 | + 0 -> field (\x up -> up {appMinFeeA = SJust x}) From |
| 670 | + 1 -> field (\x up -> up {appMinFeeB = SJust x}) From |
| 671 | + 2 -> field (\x up -> up {appMaxBBSize = SJust x}) From |
| 672 | + 3 -> field (\x up -> up {appMaxTxSize = SJust x}) From |
| 673 | + 4 -> field (\x up -> up {appMaxBHSize = SJust x}) From |
| 674 | + 5 -> field (\x up -> up {appKeyDeposit = SJust x}) From |
| 675 | + 6 -> field (\x up -> up {appPoolDeposit = SJust x}) From |
| 676 | + 7 -> field (\x up -> up {appEMax = SJust x}) From |
| 677 | + 8 -> field (\x up -> up {appNOpt = SJust x}) From |
| 678 | + 9 -> field (\x up -> up {appA0 = SJust x}) From |
| 679 | + 10 -> field (\x up -> up {appRho = SJust x}) From |
| 680 | + 11 -> field (\x up -> up {appTau = SJust x}) From |
| 681 | + 12 -> field (\x up -> up {appD = SJust x}) From |
| 682 | + 13 -> field (\x up -> up {appExtraEntropy = SJust x}) From |
| 683 | + 14 -> field (\x up -> up {appProtocolVersion = SJust x}) From |
| 684 | + 16 -> field (\x up -> up {appMinPoolCost = SJust x}) From |
| 685 | + 17 -> field (\x up -> up {appCoinsPerUTxOWord = SJust x}) From |
| 686 | + 18 -> field (\x up -> up {appCostModels = SJust x}) From |
| 687 | + 19 -> field (\x up -> up {appPrices = SJust x}) From |
| 688 | + 20 -> field (\x up -> up {appMaxTxExUnits = SJust x}) From |
| 689 | + 21 -> field (\x up -> up {appMaxBlockExUnits = SJust x}) From |
| 690 | + 22 -> field (\x up -> up {appMaxValSize = SJust x}) From |
| 691 | + 23 -> field (\x up -> up {appCollateralPercentage = SJust x}) From |
| 692 | + 24 -> field (\x up -> up {appMaxCollateralInputs = SJust x}) From |
| 693 | + k -> invalidField k |
691 | 694 |
|
692 | 695 | instance Era era => DecCBOR (AlonzoPParams StrictMaybe era) where |
693 | 696 | decCBOR = |
|
0 commit comments