Skip to content

Commit 7cf8b76

Browse files
committed
Intern stake credentials in StakePoolState CBOR decoder
1 parent db80d70 commit 7cf8b76

File tree

1 file changed

+17
-1
lines changed
  • libs/cardano-ledger-core/src/Cardano/Ledger/State

1 file changed

+17
-1
lines changed

libs/cardano-ledger-core/src/Cardano/Ledger/State/StakePool.hs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,10 @@ import Cardano.Ledger.Binary (
7575
DecShareCBOR (..),
7676
EncCBOR (..),
7777
EncCBORGroup (..),
78+
Interns,
7879
decodeNullMaybe,
7980
decodeRecordNamed,
81+
decodeRecordNamedT,
8082
decodeRecordSum,
8183
encodeListLen,
8284
encodeNullMaybe,
@@ -95,6 +97,7 @@ import Cardano.Ledger.Keys (KeyHash (..), KeyRole (..), KeyRoleVRF (StakePoolVRF
9597
import Cardano.Ledger.Orphans ()
9698
import Control.DeepSeq (NFData)
9799
import Control.Monad (unless)
100+
import Control.Monad.Trans (lift)
98101
import Data.Aeson (FromJSON (..), ToJSON (..), Value, (.!=), (.:), (.:?), (.=))
99102
import qualified Data.Aeson as Aeson
100103
import Data.Aeson.Types (Parser, explicitParseField)
@@ -200,7 +203,20 @@ instance DecCBOR StakePoolState where
200203
<! From
201204

202205
instance DecShareCBOR StakePoolState where
203-
decShareCBOR _ = decCBOR
206+
type Share StakePoolState = Interns (Credential 'Staking)
207+
decSharePlusCBOR =
208+
decodeRecordNamedT "StakePoolState" (const 10) $
209+
StakePoolState
210+
<$> lift decCBOR
211+
<*> lift decCBOR
212+
<*> lift decCBOR
213+
<*> lift decCBOR
214+
<*> lift decCBOR
215+
<*> lift decCBOR
216+
<*> lift decCBOR
217+
<*> lift decCBOR
218+
<*> lift decCBOR
219+
<*> decSharePlusCBOR
204220

205221
instance Default StakePoolState where
206222
def =

0 commit comments

Comments
 (0)