{-# OPTIONS_GHC -Wno-orphans #-}

module PlutusLedgerApi.V1.Orphans.DCert () where

import PlutusLedgerApi.QuickCheck.Utils (fromAsWord64)
import PlutusLedgerApi.V1 qualified as PLA
import PlutusLedgerApi.V1.Orphans.Credential ()
import Test.QuickCheck (
  Arbitrary (arbitrary, shrink),
  CoArbitrary (coarbitrary),
  Function (function),
  NonNegative (NonNegative),
  functionMap,
  getNonNegative,
  oneof,
  variant,
 )

-- | @since 1.0.0
instance Arbitrary PLA.DCert where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen DCert
arbitrary =
    [Gen DCert] -> Gen DCert
forall a. HasCallStack => [Gen a] -> Gen a
oneof
      [ StakingCredential -> DCert
PLA.DCertDelegRegKey (StakingCredential -> DCert) -> Gen StakingCredential -> Gen DCert
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen StakingCredential
forall a. Arbitrary a => Gen a
arbitrary
      , StakingCredential -> DCert
PLA.DCertDelegDeRegKey (StakingCredential -> DCert) -> Gen StakingCredential -> Gen DCert
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen StakingCredential
forall a. Arbitrary a => Gen a
arbitrary
      , StakingCredential -> PubKeyHash -> DCert
PLA.DCertDelegDelegate (StakingCredential -> PubKeyHash -> DCert)
-> Gen StakingCredential -> Gen (PubKeyHash -> DCert)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen StakingCredential
forall a. Arbitrary a => Gen a
arbitrary Gen (PubKeyHash -> DCert) -> Gen PubKeyHash -> Gen DCert
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Gen PubKeyHash
forall a. Arbitrary a => Gen a
arbitrary
      , PubKeyHash -> PubKeyHash -> DCert
PLA.DCertPoolRegister (PubKeyHash -> PubKeyHash -> DCert)
-> Gen PubKeyHash -> Gen (PubKeyHash -> DCert)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen PubKeyHash
forall a. Arbitrary a => Gen a
arbitrary Gen (PubKeyHash -> DCert) -> Gen PubKeyHash -> Gen DCert
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Gen PubKeyHash
forall a. Arbitrary a => Gen a
arbitrary
      , PubKeyHash -> Integer -> DCert
PLA.DCertPoolRetire (PubKeyHash -> Integer -> DCert)
-> Gen PubKeyHash -> Gen (Integer -> DCert)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen PubKeyHash
forall a. Arbitrary a => Gen a
arbitrary Gen (Integer -> DCert) -> Gen Integer -> Gen DCert
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> (AsWord64 -> Integer
fromAsWord64 (AsWord64 -> Integer) -> Gen AsWord64 -> Gen Integer
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen AsWord64
forall a. Arbitrary a => Gen a
arbitrary)
      , DCert -> Gen DCert
forall a. a -> Gen a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure DCert
PLA.DCertGenesis
      , DCert -> Gen DCert
forall a. a -> Gen a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure DCert
PLA.DCertMir
      ]
  {-# INLINEABLE shrink #-}
  shrink :: DCert -> [DCert]
shrink = \case
    PLA.DCertDelegRegKey StakingCredential
sc -> StakingCredential -> DCert
PLA.DCertDelegRegKey (StakingCredential -> DCert) -> [StakingCredential] -> [DCert]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> StakingCredential -> [StakingCredential]
forall a. Arbitrary a => a -> [a]
shrink StakingCredential
sc
    PLA.DCertDelegDeRegKey StakingCredential
sc -> StakingCredential -> DCert
PLA.DCertDelegDeRegKey (StakingCredential -> DCert) -> [StakingCredential] -> [DCert]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> StakingCredential -> [StakingCredential]
forall a. Arbitrary a => a -> [a]
shrink StakingCredential
sc
    -- PubKeyHash can't shrink, so we just pass it through, as otherwise, the
    -- semantics of shrinking would mean the whole think can't shrink.
    PLA.DCertDelegDelegate StakingCredential
sc PubKeyHash
pkh -> StakingCredential -> PubKeyHash -> DCert
PLA.DCertDelegDelegate (StakingCredential -> PubKeyHash -> DCert)
-> [StakingCredential] -> [PubKeyHash -> DCert]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> StakingCredential -> [StakingCredential]
forall a. Arbitrary a => a -> [a]
shrink StakingCredential
sc [PubKeyHash -> DCert] -> [PubKeyHash] -> [DCert]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> PubKeyHash -> [PubKeyHash]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure PubKeyHash
pkh
    -- PubKeyHash can't shrink, so neither can this.
    PLA.DCertPoolRegister PubKeyHash
_ PubKeyHash
_ -> []
    -- PubKeyHash can't shrink, so we just pass it through, as otherwise, the
    -- semantics of shrinking would mean the whole think can't shrink.
    PLA.DCertPoolRetire PubKeyHash
pkh Integer
e ->
      PubKeyHash -> Integer -> DCert
PLA.DCertPoolRetire PubKeyHash
pkh (Integer -> DCert)
-> (NonNegative Integer -> Integer) -> NonNegative Integer -> DCert
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonNegative Integer -> Integer
forall a. NonNegative a -> a
getNonNegative (NonNegative Integer -> DCert) -> [NonNegative Integer] -> [DCert]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> NonNegative Integer -> [NonNegative Integer]
forall a. Arbitrary a => a -> [a]
shrink (Integer -> NonNegative Integer
forall a. a -> NonNegative a
NonNegative Integer
e)
    -- None of the other constructors have any data, so we don't shrink them.
    DCert
_ -> []

-- | @since 1.0.0
instance CoArbitrary PLA.DCert where
  {-# INLINEABLE coarbitrary #-}
  coarbitrary :: forall b. DCert -> Gen b -> Gen b
coarbitrary = \case
    PLA.DCertDelegRegKey StakingCredential
sc -> Int -> Gen b -> Gen b
forall n a. Integral n => n -> Gen a -> Gen a
variant (Int
0 :: Int) (Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StakingCredential -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. StakingCredential -> Gen b -> Gen b
coarbitrary StakingCredential
sc
    PLA.DCertDelegDeRegKey StakingCredential
sc -> Int -> Gen b -> Gen b
forall n a. Integral n => n -> Gen a -> Gen a
variant (Int
1 :: Int) (Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StakingCredential -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. StakingCredential -> Gen b -> Gen b
coarbitrary StakingCredential
sc
    PLA.DCertDelegDelegate StakingCredential
sc PubKeyHash
pkh -> Int -> Gen b -> Gen b
forall n a. Integral n => n -> Gen a -> Gen a
variant (Int
2 :: Int) (Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StakingCredential -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. StakingCredential -> Gen b -> Gen b
coarbitrary StakingCredential
sc (Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PubKeyHash -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. PubKeyHash -> Gen b -> Gen b
coarbitrary PubKeyHash
pkh
    PLA.DCertPoolRegister PubKeyHash
pkh PubKeyHash
pkh' -> Int -> Gen b -> Gen b
forall n a. Integral n => n -> Gen a -> Gen a
variant (Int
3 :: Int) (Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PubKeyHash -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. PubKeyHash -> Gen b -> Gen b
coarbitrary PubKeyHash
pkh (Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PubKeyHash -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. PubKeyHash -> Gen b -> Gen b
coarbitrary PubKeyHash
pkh'
    PLA.DCertPoolRetire PubKeyHash
pkh Integer
e -> Int -> Gen b -> Gen b
forall n a. Integral n => n -> Gen a -> Gen a
variant (Int
4 :: Int) (Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PubKeyHash -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. PubKeyHash -> Gen b -> Gen b
coarbitrary PubKeyHash
pkh (Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Gen b -> Gen b
forall b. Integer -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary Integer
e
    DCert
PLA.DCertGenesis -> Int -> Gen b -> Gen b
forall n a. Integral n => n -> Gen a -> Gen a
variant (Int
5 :: Int)
    DCert
PLA.DCertMir -> Int -> Gen b -> Gen b
forall n a. Integral n => n -> Gen a -> Gen a
variant (Int
6 :: Int)

-- | @since 1.0.0
instance Function PLA.DCert where
  {-# INLINEABLE function #-}
  function :: forall b. (DCert -> b) -> DCert :-> b
function = (DCert
 -> Maybe
      (Maybe
         (Either
            StakingCredential
            (Either
               StakingCredential
               (Either
                  (StakingCredential, PubKeyHash)
                  (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))))))
-> (Maybe
      (Maybe
         (Either
            StakingCredential
            (Either
               StakingCredential
               (Either
                  (StakingCredential, PubKeyHash)
                  (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))))
    -> DCert)
-> (DCert -> b)
-> DCert :-> b
forall b a c.
Function b =>
(a -> b) -> (b -> a) -> (a -> c) -> a :-> c
functionMap DCert
-> Maybe
     (Maybe
        (Either
           StakingCredential
           (Either
              StakingCredential
              (Either
                 (StakingCredential, PubKeyHash)
                 (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))))
into Maybe
  (Maybe
     (Either
        StakingCredential
        (Either
           StakingCredential
           (Either
              (StakingCredential, PubKeyHash)
              (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))))
-> DCert
outOf
    where
      into ::
        PLA.DCert ->
        Maybe
          ( Maybe
              ( Either
                  PLA.StakingCredential
                  ( Either
                      PLA.StakingCredential
                      ( Either
                          (PLA.StakingCredential, PLA.PubKeyHash)
                          ( Either (PLA.PubKeyHash, PLA.PubKeyHash) (PLA.PubKeyHash, Integer)
                          )
                      )
                  )
              )
          )
      into :: DCert
-> Maybe
     (Maybe
        (Either
           StakingCredential
           (Either
              StakingCredential
              (Either
                 (StakingCredential, PubKeyHash)
                 (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))))
into = \case
        DCert
PLA.DCertGenesis -> Maybe
  (Maybe
     (Either
        StakingCredential
        (Either
           StakingCredential
           (Either
              (StakingCredential, PubKeyHash)
              (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))))
forall a. Maybe a
Nothing
        DCert
PLA.DCertMir -> Maybe
  (Either
     StakingCredential
     (Either
        StakingCredential
        (Either
           (StakingCredential, PubKeyHash)
           (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))))
-> Maybe
     (Maybe
        (Either
           StakingCredential
           (Either
              StakingCredential
              (Either
                 (StakingCredential, PubKeyHash)
                 (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))))
forall a. a -> Maybe a
Just Maybe
  (Either
     StakingCredential
     (Either
        StakingCredential
        (Either
           (StakingCredential, PubKeyHash)
           (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))))
forall a. Maybe a
Nothing
        PLA.DCertDelegRegKey StakingCredential
sc -> Maybe
  (Either
     StakingCredential
     (Either
        StakingCredential
        (Either
           (StakingCredential, PubKeyHash)
           (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))))
-> Maybe
     (Maybe
        (Either
           StakingCredential
           (Either
              StakingCredential
              (Either
                 (StakingCredential, PubKeyHash)
                 (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))))
forall a. a -> Maybe a
Just (Either
  StakingCredential
  (Either
     StakingCredential
     (Either
        (StakingCredential, PubKeyHash)
        (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))
-> Maybe
     (Either
        StakingCredential
        (Either
           StakingCredential
           (Either
              (StakingCredential, PubKeyHash)
              (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))))
forall a. a -> Maybe a
Just (StakingCredential
-> Either
     StakingCredential
     (Either
        StakingCredential
        (Either
           (StakingCredential, PubKeyHash)
           (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))
forall a b. a -> Either a b
Left StakingCredential
sc))
        PLA.DCertDelegDeRegKey StakingCredential
sc -> Maybe
  (Either
     StakingCredential
     (Either
        StakingCredential
        (Either
           (StakingCredential, PubKeyHash)
           (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))))
-> Maybe
     (Maybe
        (Either
           StakingCredential
           (Either
              StakingCredential
              (Either
                 (StakingCredential, PubKeyHash)
                 (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))))
forall a. a -> Maybe a
Just (Either
  StakingCredential
  (Either
     StakingCredential
     (Either
        (StakingCredential, PubKeyHash)
        (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))
-> Maybe
     (Either
        StakingCredential
        (Either
           StakingCredential
           (Either
              (StakingCredential, PubKeyHash)
              (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))))
forall a. a -> Maybe a
Just (Either
  StakingCredential
  (Either
     (StakingCredential, PubKeyHash)
     (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))
-> Either
     StakingCredential
     (Either
        StakingCredential
        (Either
           (StakingCredential, PubKeyHash)
           (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))
forall a b. b -> Either a b
Right (StakingCredential
-> Either
     StakingCredential
     (Either
        (StakingCredential, PubKeyHash)
        (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))
forall a b. a -> Either a b
Left StakingCredential
sc)))
        PLA.DCertDelegDelegate StakingCredential
sc PubKeyHash
pkh -> Maybe
  (Either
     StakingCredential
     (Either
        StakingCredential
        (Either
           (StakingCredential, PubKeyHash)
           (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))))
-> Maybe
     (Maybe
        (Either
           StakingCredential
           (Either
              StakingCredential
              (Either
                 (StakingCredential, PubKeyHash)
                 (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))))
forall a. a -> Maybe a
Just (Either
  StakingCredential
  (Either
     StakingCredential
     (Either
        (StakingCredential, PubKeyHash)
        (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))
-> Maybe
     (Either
        StakingCredential
        (Either
           StakingCredential
           (Either
              (StakingCredential, PubKeyHash)
              (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))))
forall a. a -> Maybe a
Just (Either
  StakingCredential
  (Either
     (StakingCredential, PubKeyHash)
     (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))
-> Either
     StakingCredential
     (Either
        StakingCredential
        (Either
           (StakingCredential, PubKeyHash)
           (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))
forall a b. b -> Either a b
Right (Either
  (StakingCredential, PubKeyHash)
  (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))
-> Either
     StakingCredential
     (Either
        (StakingCredential, PubKeyHash)
        (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))
forall a b. b -> Either a b
Right ((StakingCredential, PubKeyHash)
-> Either
     (StakingCredential, PubKeyHash)
     (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))
forall a b. a -> Either a b
Left (StakingCredential
sc, PubKeyHash
pkh)))))
        PLA.DCertPoolRegister PubKeyHash
pkh PubKeyHash
pkh' -> Maybe
  (Either
     StakingCredential
     (Either
        StakingCredential
        (Either
           (StakingCredential, PubKeyHash)
           (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))))
-> Maybe
     (Maybe
        (Either
           StakingCredential
           (Either
              StakingCredential
              (Either
                 (StakingCredential, PubKeyHash)
                 (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))))
forall a. a -> Maybe a
Just (Either
  StakingCredential
  (Either
     StakingCredential
     (Either
        (StakingCredential, PubKeyHash)
        (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))
-> Maybe
     (Either
        StakingCredential
        (Either
           StakingCredential
           (Either
              (StakingCredential, PubKeyHash)
              (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))))
forall a. a -> Maybe a
Just (Either
  StakingCredential
  (Either
     (StakingCredential, PubKeyHash)
     (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))
-> Either
     StakingCredential
     (Either
        StakingCredential
        (Either
           (StakingCredential, PubKeyHash)
           (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))
forall a b. b -> Either a b
Right (Either
  (StakingCredential, PubKeyHash)
  (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))
-> Either
     StakingCredential
     (Either
        (StakingCredential, PubKeyHash)
        (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))
forall a b. b -> Either a b
Right (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)
-> Either
     (StakingCredential, PubKeyHash)
     (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))
forall a b. b -> Either a b
Right ((PubKeyHash, PubKeyHash)
-> Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)
forall a b. a -> Either a b
Left (PubKeyHash
pkh, PubKeyHash
pkh'))))))
        PLA.DCertPoolRetire PubKeyHash
pkh Integer
e -> Maybe
  (Either
     StakingCredential
     (Either
        StakingCredential
        (Either
           (StakingCredential, PubKeyHash)
           (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))))
-> Maybe
     (Maybe
        (Either
           StakingCredential
           (Either
              StakingCredential
              (Either
                 (StakingCredential, PubKeyHash)
                 (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))))
forall a. a -> Maybe a
Just (Either
  StakingCredential
  (Either
     StakingCredential
     (Either
        (StakingCredential, PubKeyHash)
        (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))
-> Maybe
     (Either
        StakingCredential
        (Either
           StakingCredential
           (Either
              (StakingCredential, PubKeyHash)
              (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))))
forall a. a -> Maybe a
Just (Either
  StakingCredential
  (Either
     (StakingCredential, PubKeyHash)
     (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))
-> Either
     StakingCredential
     (Either
        StakingCredential
        (Either
           (StakingCredential, PubKeyHash)
           (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))
forall a b. b -> Either a b
Right (Either
  (StakingCredential, PubKeyHash)
  (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))
-> Either
     StakingCredential
     (Either
        (StakingCredential, PubKeyHash)
        (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))
forall a b. b -> Either a b
Right (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)
-> Either
     (StakingCredential, PubKeyHash)
     (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))
forall a b. b -> Either a b
Right ((PubKeyHash, Integer)
-> Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)
forall a b. b -> Either a b
Right (PubKeyHash
pkh, Integer
e))))))
      outOf ::
        Maybe
          ( Maybe
              ( Either
                  PLA.StakingCredential
                  ( Either
                      PLA.StakingCredential
                      ( Either
                          (PLA.StakingCredential, PLA.PubKeyHash)
                          ( Either (PLA.PubKeyHash, PLA.PubKeyHash) (PLA.PubKeyHash, Integer)
                          )
                      )
                  )
              )
          ) ->
        PLA.DCert
      outOf :: Maybe
  (Maybe
     (Either
        StakingCredential
        (Either
           StakingCredential
           (Either
              (StakingCredential, PubKeyHash)
              (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))))
-> DCert
outOf = \case
        Maybe
  (Maybe
     (Either
        StakingCredential
        (Either
           StakingCredential
           (Either
              (StakingCredential, PubKeyHash)
              (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer))))))
Nothing -> DCert
PLA.DCertGenesis
        Just Maybe
  (Either
     StakingCredential
     (Either
        StakingCredential
        (Either
           (StakingCredential, PubKeyHash)
           (Either (PubKeyHash, PubKeyHash) (PubKeyHash, Integer)))))
Nothing -> DCert
PLA.DCertMir
        Just (Just (Left StakingCredential
sc)) -> StakingCredential -> DCert
PLA.DCertDelegRegKey StakingCredential
sc
        Just (Just (Right (Left StakingCredential
sc))) -> StakingCredential -> DCert
PLA.DCertDelegDeRegKey StakingCredential
sc
        Just (Just (Right (Right (Left (StakingCredential
sc, PubKeyHash
pkh))))) -> StakingCredential -> PubKeyHash -> DCert
PLA.DCertDelegDelegate StakingCredential
sc PubKeyHash
pkh
        Just (Just (Right (Right (Right (Left (PubKeyHash
pkh, PubKeyHash
pkh')))))) -> PubKeyHash -> PubKeyHash -> DCert
PLA.DCertPoolRegister PubKeyHash
pkh PubKeyHash
pkh'
        Just (Just (Right (Right (Right (Right (PubKeyHash
pkh, Integer
e)))))) -> PubKeyHash -> Integer -> DCert
PLA.DCertPoolRetire PubKeyHash
pkh Integer
e