Skip to content

Commit ab3f025

Browse files
authored
Merge pull request #5553 from IntersectMBO/nm/cardano-base-orphans
Move `Arbitrary` instances to `cardano-base`
2 parents 43dd6f9 + a4e813c commit ab3f025

File tree

60 files changed

+170
-225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+170
-225
lines changed

cabal.project

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ source-repository-package
2828
-- see CONTRIBUTING.md#to-update-the-referenced-agda-ledger-spec
2929
index-state:
3030
, hackage.haskell.org 2025-12-11T11:28:18Z
31-
, cardano-haskell-packages 2025-12-10T11:48:32Z
31+
, cardano-haskell-packages 2026-02-17T21:19:19Z
3232

3333
packages:
3434
-- == Byron era ==
@@ -91,6 +91,9 @@ tests: true
9191
benchmarks: true
9292
-- The only sensible test display option
9393
test-show-details: streaming
94+
allow-newer:
95+
-- Drop this when the bounds in plutus-core are updated
96+
plutus-core:cardano-crypto-class
9497

9598
if impl(ghc >=9.12)
9699
allow-newer:

eras/byron/ledger/impl/cardano-ledger-byron.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ library
240240
binary,
241241
bytestring,
242242
canonical-json,
243-
cardano-binary,
243+
cardano-binary >=1.7.3,
244244
cardano-crypto,
245245
cardano-crypto-wrapper >=1.6,
246246
cardano-ledger-binary >=1.8,
@@ -346,7 +346,7 @@ library testlib
346346
byron-spec-chain,
347347
byron-spec-ledger,
348348
bytestring,
349-
cardano-binary:{cardano-binary, testlib} >=1.7.2,
349+
cardano-binary:{cardano-binary, testlib},
350350
cardano-crypto,
351351
cardano-crypto-wrapper:{cardano-crypto-wrapper, testlib},
352352
cardano-ledger-binary:{cardano-ledger-binary, testlib},

eras/byron/ledger/impl/src/Cardano/Chain/Block/Block.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ decCBORABlockOrBoundary epochSlots = do
417417
decCBOR @Word >>= \case
418418
0 -> ABOBBoundary <$> decCBORABoundaryBlock
419419
1 -> ABOBBlock <$> decCBORABlock epochSlots
420-
t -> cborError $ DecoderErrorUnknownTag "Block" (fromIntegral t)
420+
t -> cborError $ DecoderErrorUnknownTag "Block" t
421421

422422
encCBORABlockOrBoundary ::
423423
ProtocolMagicId -> EpochSlots -> ABlockOrBoundary a -> Encoding

eras/byron/ledger/impl/src/Cardano/Chain/Block/Header.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ decCBORHeaderToHash epochSlots = do
415415
void decCBORABoundaryHeader
416416
pure Nothing
417417
1 -> Just <$!> decCBORHeader epochSlots
418-
t -> cborError $ DecoderErrorUnknownTag "Header" (fromIntegral t)
418+
t -> cborError $ DecoderErrorUnknownTag "Header" t
419419

420420
--------------------------------------------------------------------------------
421421
-- Header Formatting
@@ -691,13 +691,13 @@ instance DecCBOR BlockSignature where
691691
instance DecCBOR (ABlockSignature ByteSpan) where
692692
decCBOR = do
693693
enforceSize "BlockSignature" 2
694-
decCBOR >>= \case
694+
decCBOR @Word8 >>= \case
695695
2 ->
696696
ABlockSignature
697697
<$ enforceSize "BlockSignature" 2
698698
<*> decCBOR
699699
<*> decCBOR
700-
t -> cborError $ DecoderErrorUnknownTag "BlockSignature" t
700+
t -> cborError $ DecoderErrorUnknownTag "BlockSignature" $ fromIntegral @Word8 @Word t
701701

702702
--------------------------------------------------------------------------------
703703
-- ToSign

eras/byron/ledger/impl/src/Cardano/Chain/Byron/API/Mempool.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{-# LANGUAGE LambdaCase #-}
44
{-# LANGUAGE OverloadedStrings #-}
55
{-# LANGUAGE RankNTypes #-}
6+
{-# LANGUAGE TypeApplications #-}
67

78
module Cardano.Chain.Byron.API.Mempool (
89
ApplyMempoolPayloadErr (..),
@@ -70,7 +71,7 @@ instance DecCBOR ApplyMempoolPayloadErr where
7071
1 -> MempoolDlgErr <$> decCBOR
7172
2 -> MempoolUpdateProposalErr <$> decCBOR
7273
3 -> MempoolUpdateVoteErr <$> decCBOR
73-
tag -> cborError $ DecoderErrorUnknownTag "ApplyMempoolPayloadErr" tag
74+
tag -> cborError $ DecoderErrorUnknownTag "ApplyMempoolPayloadErr" $ fromIntegral @Word8 @Word tag
7475

7576
applyMempoolPayload ::
7677
MonadError ApplyMempoolPayloadErr m =>

eras/byron/ledger/impl/src/Cardano/Chain/Common/AddrSpendingData.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ instance DecCBOR AddrSpendingData where
7777
decodeWord8Canonical >>= \case
7878
0 -> VerKeyASD <$> decCBOR
7979
2 -> RedeemASD <$> decCBOR
80-
tag -> cborError $ DecoderErrorUnknownTag "AddrSpendingData" tag
80+
tag -> cborError $ DecoderErrorUnknownTag "AddrSpendingData" $ fromIntegral @Word8 @Word tag
8181

8282
-- | Type of an address. It corresponds to constructors of 'AddrSpendingData'.
8383
-- It's separated, because 'Address' doesn't store 'AddrSpendingData', but we
@@ -110,7 +110,7 @@ instance DecCBOR AddrType where
110110
decodeWord8Canonical >>= \case
111111
0 -> pure ATVerKey
112112
2 -> pure ATRedeem
113-
tag -> cborError $ DecoderErrorUnknownTag "AddrType" tag
113+
tag -> cborError $ DecoderErrorUnknownTag "AddrType" $ fromIntegral @Word8 @Word tag
114114

115115
instance HeapWords AddrType where
116116
heapWords = \case

eras/byron/ledger/impl/src/Cardano/Chain/Common/Lovelace.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ instance DecCBOR LovelaceError where
173173
1 -> checkSize 2 >> LovelaceTooLarge <$> decCBOR
174174
2 -> checkSize 2 >> LovelaceTooSmall <$> decCBOR
175175
3 -> checkSize 3 >> LovelaceUnderflow <$> decCBOR <*> decCBOR
176-
_ -> cborError $ DecoderErrorUnknownTag "TxValidationError" tag
176+
_ -> cborError $ DecoderErrorUnknownTag "TxValidationError" $ fromIntegral @Word8 @Word tag
177177

178178
-- | Maximal possible value of 'Lovelace'
179179
maxLovelaceVal :: Word64

eras/byron/ledger/impl/src/Cardano/Chain/Common/NetworkMagic.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ instance DecCBOR NetworkMagic where
7575
case tag of
7676
0 -> matchSize "NetworkMagic" 1 len $> NetworkMainOrStage
7777
1 -> matchSize "NetworkMagic" 2 len >> NetworkTestnet <$> decCBOR
78-
_ -> cborError $ DecoderErrorUnknownTag "NetworkMagic" tag
78+
_ -> cborError $ DecoderErrorUnknownTag "NetworkMagic" $ fromIntegral @Word8 @Word tag
7979

8080
makeNetworkMagic :: AProtocolMagic a -> NetworkMagic
8181
makeNetworkMagic pm = case getRequiresNetworkMagic pm of

eras/byron/ledger/impl/src/Cardano/Chain/Common/TxFeePolicy.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ instance DecCBOR TxFeePolicy where
9696
tag <- decCBOR @Word8
9797
case tag of
9898
0 -> TxFeePolicyTxSizeLinear <$> decodeKnownCborDataItem
99-
_ -> cborError $ DecoderErrorUnknownTag "TxFeePolicy" tag
99+
_ -> cborError $ DecoderErrorUnknownTag "TxFeePolicy" $ fromIntegral @Word8 @Word tag
100100

101101
instance Monad m => ToJSON m TxFeePolicy where
102102
-- We multiply by 1e9 to keep compatibility with 'Nano' coefficients

eras/byron/ledger/impl/src/Cardano/Chain/Delegation/Validation/Scheduling.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{-# LANGUAGE FlexibleContexts #-}
44
{-# LANGUAGE NamedFieldPuns #-}
55
{-# LANGUAGE OverloadedStrings #-}
6+
{-# LANGUAGE TypeApplications #-}
67

78
module Cardano.Chain.Delegation.Validation.Scheduling (
89
-- * Scheduling
@@ -168,7 +169,7 @@ instance DecCBOR Error where
168169
2 -> checkSize 3 >> MultipleDelegationsForSlot <$> decCBOR <*> decCBOR
169170
3 -> checkSize 2 >> NonGenesisDelegator <$> decCBOR
170171
4 -> checkSize 3 >> WrongEpoch <$> decCBOR <*> decCBOR
171-
_ -> cborError $ DecoderErrorUnknownTag "Scheduling.Error" tag
172+
_ -> cborError $ DecoderErrorUnknownTag "Scheduling.Error" $ fromIntegral @Word8 @Word tag
172173

173174
-- | Update the delegation 'State' with a 'Certificate' if it passes
174175
-- all the validation rules. This is an implementation of the delegation

0 commit comments

Comments
 (0)