{-# OPTIONS_GHC -Wno-orphans #-}

module PlutusLedgerApi.V4.Orphans where

import Control.Applicative (asum, (<|>))
import Control.Monad (guard)
import Data.Coerce (coerce)
import Data.Maybe (fromJust)
import Data.These (These (That, These, This), these)
import PlutusLedgerApi.V1.Orphans.Value qualified as Value
import PlutusLedgerApi.V3.Orphans ()
import PlutusLedgerApi.V4 qualified as PLA
import PlutusLedgerApi.V4.Ratio qualified as Ratio
import PlutusTx.AssocMap qualified as AssocMap
import Test.QuickCheck (
  Arbitrary (arbitrary, shrink),
  CoArbitrary (coarbitrary),
  Function (function),
  NonEmptyList (NonEmpty),
  NonNegative (NonNegative),
  Positive (Positive),
  chooseInt,
  functionMap,
  getNonEmpty,
  getNonNegative,
  getPositive,
  liftArbitrary,
  liftShrink,
  oneof,
  variant,
 )

-- | @since 1.4.0
instance Arbitrary PLA.Rational where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen Rational
arbitrary = do
    Int
den <- (Int, Int) -> Gen Int
chooseInt (Int
1, Int
100)
    Int
num <- (Int, Int) -> Gen Int
chooseInt (-Int
100, Int
100)
    Rational -> Gen Rational
forall a. a -> Gen a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Rational -> Gen Rational)
-> (Int -> Rational) -> Int -> Gen Rational
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe Rational -> Rational
forall a. HasCallStack => Maybe a -> a
fromJust (Maybe Rational -> Rational)
-> (Int -> Maybe Rational) -> Int -> Rational
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer -> Maybe Rational
PLA.ratio (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
num) (Integer -> Maybe Rational)
-> (Int -> Integer) -> Int -> Maybe Rational
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Gen Rational) -> Int -> Gen Rational
forall a b. (a -> b) -> a -> b
$ Int
den
  {-# INLINEABLE shrink #-}
  shrink :: Rational -> [Rational]
shrink Rational
r = do
    let n :: Integer
n = Rational -> Integer
PLA.numerator Rational
r
    let d :: Integer
d = Rational -> Integer
PLA.denominator Rational
r
    Integer
n' <- Integer -> [Integer]
forall a. Arbitrary a => a -> [a]
shrink Integer
n
    Rational -> [Rational]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Rational -> [Rational])
-> (Integer -> Rational) -> Integer -> [Rational]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe Rational -> Rational
forall a. HasCallStack => Maybe a -> a
fromJust (Maybe Rational -> Rational)
-> (Integer -> Maybe Rational) -> Integer -> Rational
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer -> Maybe Rational
PLA.ratio Integer
n' (Integer -> [Rational]) -> Integer -> [Rational]
forall a b. (a -> b) -> a -> b
$ Integer
d

-- | @since 1.4.0
instance CoArbitrary PLA.Rational where
  {-# INLINEABLE coarbitrary #-}
  coarbitrary :: forall b. Rational -> Gen b -> Gen b
coarbitrary Rational
r =
    Integer -> Gen b -> Gen b
forall b. Integer -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary (Rational -> Integer
PLA.numerator Rational
r)
      (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 (Rational -> Integer
PLA.denominator Rational
r)

-- | @since 1.4.0
instance Function PLA.Rational where
  {-# INLINE function #-}
  function :: forall b. (Rational -> b) -> Rational :-> b
function = (Rational -> (Integer, Integer))
-> ((Integer, Integer) -> Rational)
-> (Rational -> b)
-> Rational :-> b
forall b a c.
Function b =>
(a -> b) -> (b -> a) -> (a -> c) -> a :-> c
functionMap Rational -> (Integer, Integer)
into (Integer, Integer) -> Rational
outOf
    where
      into :: PLA.Rational -> (Integer, Integer)
      into :: Rational -> (Integer, Integer)
into Rational
r = (Rational -> Integer
PLA.numerator Rational
r, Rational -> Integer
PLA.denominator Rational
r)
      outOf :: (Integer, Integer) -> PLA.Rational
      outOf :: (Integer, Integer) -> Rational
outOf (Integer
n, Integer
d) = Integer -> Integer -> Rational
PLA.unsafeRatio Integer
n Integer
d

{- | Does not shrink the quorum, as this is surprisingly hard to do sensibly. We
assume the quorum is in the interval @(0, 1]@ (meaning anywhere from a single
voice to unanimity).

@since 1.4.0
-}
instance Arbitrary PLA.Committee where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen Committee
arbitrary = do
    Map ColdCommitteeCredential Integer
committee <- Gen Integer -> Gen (Map ColdCommitteeCredential Integer)
forall a. Gen a -> Gen (Map ColdCommitteeCredential a)
forall (f :: Type -> Type) a. Arbitrary1 f => Gen a -> Gen (f a)
liftArbitrary (Positive Integer -> Integer
forall a. Positive a -> a
getPositive (Positive Integer -> Integer)
-> Gen (Positive Integer) -> Gen Integer
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Positive Integer)
forall a. Arbitrary a => Gen a
arbitrary)
    -- We can't have a quorum of 0.0
    Int
num <- (Int, Int) -> Gen Int
chooseInt (Int
1, Int
100)
    let quorum :: Rational
quorum = Integer -> Integer -> Rational
Ratio.unsafeRatio (Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
num) Integer
100
    Committee -> Gen Committee
forall a. a -> Gen a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Committee -> Gen Committee)
-> (Rational -> Committee) -> Rational -> Gen Committee
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map ColdCommitteeCredential Integer -> Rational -> Committee
PLA.Committee Map ColdCommitteeCredential Integer
committee (Rational -> Gen Committee) -> Rational -> Gen Committee
forall a b. (a -> b) -> a -> b
$ Rational
quorum
  {-# INLINEABLE shrink #-}
  shrink :: Committee -> [Committee]
shrink (PLA.Committee Map ColdCommitteeCredential Integer
committee Rational
quorum) = do
    Map ColdCommitteeCredential Integer
committee' <- (Integer -> [Integer])
-> Map ColdCommitteeCredential Integer
-> [Map ColdCommitteeCredential Integer]
forall a.
(a -> [a])
-> Map ColdCommitteeCredential a -> [Map ColdCommitteeCredential a]
forall (f :: Type -> Type) a.
Arbitrary1 f =>
(a -> [a]) -> f a -> [f a]
liftShrink ((Positive Integer -> Integer) -> [Positive Integer] -> [Integer]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap Positive Integer -> Integer
forall a. Positive a -> a
getPositive ([Positive Integer] -> [Integer])
-> (Integer -> [Positive Integer]) -> Integer -> [Integer]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Positive Integer -> [Positive Integer]
forall a. Arbitrary a => a -> [a]
shrink (Positive Integer -> [Positive Integer])
-> (Integer -> Positive Integer) -> Integer -> [Positive Integer]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Positive Integer
forall a. a -> Positive a
Positive) Map ColdCommitteeCredential Integer
committee
    Bool -> [()]
forall (f :: Type -> Type). Alternative f => Bool -> f ()
guard (Bool -> Bool
not (Bool -> Bool)
-> (Map ColdCommitteeCredential Integer -> Bool)
-> Map ColdCommitteeCredential Integer
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map ColdCommitteeCredential Integer -> Bool
forall k v. Map k v -> Bool
AssocMap.null (Map ColdCommitteeCredential Integer -> Bool)
-> Map ColdCommitteeCredential Integer -> Bool
forall a b. (a -> b) -> a -> b
$ Map ColdCommitteeCredential Integer
committee')
    Committee -> [Committee]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Committee -> [Committee])
-> (Rational -> Committee) -> Rational -> [Committee]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map ColdCommitteeCredential Integer -> Rational -> Committee
PLA.Committee Map ColdCommitteeCredential Integer
committee' (Rational -> [Committee]) -> Rational -> [Committee]
forall a b. (a -> b) -> a -> b
$ Rational
quorum

-- | @since 1.4.0
instance CoArbitrary PLA.Committee where
  {-# INLINEABLE coarbitrary #-}
  coarbitrary :: forall b. Committee -> Gen b -> Gen b
coarbitrary (PLA.Committee Map ColdCommitteeCredential Integer
committee Rational
quorum) =
    Map ColdCommitteeCredential Integer -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. Map ColdCommitteeCredential Integer -> Gen b -> Gen b
coarbitrary Map ColdCommitteeCredential Integer
committee
      (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 (Rational -> Integer
Ratio.numerator Rational
quorum)
      (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 (Rational -> Integer
Ratio.denominator Rational
quorum)

-- | @since 1.4.0
instance Function PLA.Committee where
  {-# INLINEABLE function #-}
  function :: forall b. (Committee -> b) -> Committee :-> b
function = (Committee
 -> (Map ColdCommitteeCredential Integer, Integer, Integer))
-> ((Map ColdCommitteeCredential Integer, Integer, Integer)
    -> Committee)
-> (Committee -> b)
-> Committee :-> b
forall b a c.
Function b =>
(a -> b) -> (b -> a) -> (a -> c) -> a :-> c
functionMap Committee
-> (Map ColdCommitteeCredential Integer, Integer, Integer)
into (Map ColdCommitteeCredential Integer, Integer, Integer)
-> Committee
outOf
    where
      into ::
        PLA.Committee ->
        (PLA.Map PLA.ColdCommitteeCredential Integer, Integer, Integer)
      into :: Committee
-> (Map ColdCommitteeCredential Integer, Integer, Integer)
into (PLA.Committee Map ColdCommitteeCredential Integer
committee Rational
quorum) =
        (Map ColdCommitteeCredential Integer
committee, Rational -> Integer
Ratio.numerator Rational
quorum, Rational -> Integer
Ratio.denominator Rational
quorum)
      outOf ::
        (PLA.Map PLA.ColdCommitteeCredential Integer, Integer, Integer) ->
        PLA.Committee
      outOf :: (Map ColdCommitteeCredential Integer, Integer, Integer)
-> Committee
outOf (Map ColdCommitteeCredential Integer
committee, Integer
num, Integer
den) =
        Map ColdCommitteeCredential Integer -> Rational -> Committee
PLA.Committee Map ColdCommitteeCredential Integer
committee (Rational -> Committee)
-> (Integer -> Rational) -> Integer -> Committee
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer -> Rational
Ratio.unsafeRatio Integer
num (Integer -> Committee) -> Integer -> Committee
forall a b. (a -> b) -> a -> b
$ Integer
den

-- | @since 1.4.0
deriving via PLA.Credential instance Arbitrary PLA.AccountId

-- | @since 1.4.0
deriving via PLA.Credential instance CoArbitrary PLA.AccountId

-- | @since 1.4.0
instance Function PLA.AccountId where
  {-# INLINEABLE function #-}
  function :: forall b. (AccountId -> b) -> AccountId :-> b
function = (AccountId -> Credential)
-> (Credential -> AccountId) -> (AccountId -> b) -> AccountId :-> b
forall b a c.
Function b =>
(a -> b) -> (b -> a) -> (a -> c) -> a :-> c
functionMap AccountId -> Credential
forall a b. Coercible a b => a -> b
coerce Credential -> AccountId
PLA.AccountId

-- | @since 1.4.0
instance Arbitrary PLA.Address where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen Address
arbitrary = Credential -> Maybe AccountId -> Address
PLA.Address (Credential -> Maybe AccountId -> Address)
-> Gen Credential -> Gen (Maybe AccountId -> Address)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Credential
forall a. Arbitrary a => Gen a
arbitrary Gen (Maybe AccountId -> Address)
-> Gen (Maybe AccountId) -> Gen Address
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 (Maybe AccountId)
forall a. Arbitrary a => Gen a
arbitrary
  {-# INLINEABLE shrink #-}
  shrink :: Address -> [Address]
shrink (PLA.Address Credential
cred Maybe AccountId
mAccId) = Credential -> Maybe AccountId -> Address
PLA.Address Credential
cred (Maybe AccountId -> Address) -> [Maybe AccountId] -> [Address]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe AccountId -> [Maybe AccountId]
forall a. Arbitrary a => a -> [a]
shrink Maybe AccountId
mAccId

-- | @since 1.4.0
instance CoArbitrary PLA.Address where
  {-# INLINEABLE coarbitrary #-}
  coarbitrary :: forall b. Address -> Gen b -> Gen b
coarbitrary (PLA.Address Credential
cred Maybe AccountId
mAccId) = Credential -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. Credential -> Gen b -> Gen b
coarbitrary Credential
cred (Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe AccountId -> Gen b -> Gen b
forall b. Maybe AccountId -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary Maybe AccountId
mAccId

-- | @since 1.4.0
instance Function PLA.Address where
  {-# INLINEABLE function #-}
  function :: forall b. (Address -> b) -> Address :-> b
function = (Address -> (Credential, Maybe AccountId))
-> ((Credential, Maybe AccountId) -> Address)
-> (Address -> b)
-> Address :-> b
forall b a c.
Function b =>
(a -> b) -> (b -> a) -> (a -> c) -> a :-> c
functionMap Address -> (Credential, Maybe AccountId)
into (Credential, Maybe AccountId) -> Address
outOf
    where
      into :: PLA.Address -> (PLA.Credential, Maybe PLA.AccountId)
      into :: Address -> (Credential, Maybe AccountId)
into (PLA.Address Credential
cred Maybe AccountId
mAccId) = (Credential
cred, Maybe AccountId
mAccId)
      outOf :: (PLA.Credential, Maybe PLA.AccountId) -> PLA.Address
      outOf :: (Credential, Maybe AccountId) -> Address
outOf = (Credential -> Maybe AccountId -> Address)
-> (Credential, Maybe AccountId) -> Address
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Credential -> Maybe AccountId -> Address
PLA.Address

-- | @since 1.4.0
instance Arbitrary PLA.TxOut where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen TxOut
arbitrary =
    Address -> Value -> OutputDatum -> Maybe ScriptHash -> TxOut
PLA.TxOut
      (Address -> Value -> OutputDatum -> Maybe ScriptHash -> TxOut)
-> Gen Address
-> Gen (Value -> OutputDatum -> Maybe ScriptHash -> TxOut)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Address
forall a. Arbitrary a => Gen a
arbitrary
      Gen (Value -> OutputDatum -> Maybe ScriptHash -> TxOut)
-> Gen Value -> Gen (OutputDatum -> Maybe ScriptHash -> TxOut)
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
<*> (UTxOValue -> Value
Value.getUtxoValue (UTxOValue -> Value) -> Gen UTxOValue -> Gen Value
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen UTxOValue
forall a. Arbitrary a => Gen a
arbitrary)
      Gen (OutputDatum -> Maybe ScriptHash -> TxOut)
-> Gen OutputDatum -> Gen (Maybe ScriptHash -> TxOut)
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 OutputDatum
forall a. Arbitrary a => Gen a
arbitrary
      Gen (Maybe ScriptHash -> TxOut)
-> Gen (Maybe ScriptHash) -> Gen TxOut
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 (Maybe ScriptHash)
forall a. Arbitrary a => Gen a
arbitrary
  {-# INLINEABLE shrink #-}
  shrink :: TxOut -> [TxOut]
shrink (PLA.TxOut Address
addr Value
val OutputDatum
outD Maybe ScriptHash
refScript) =
    [[TxOut]] -> [TxOut]
forall (t :: Type -> Type) (f :: Type -> Type) a.
(Foldable t, Alternative f) =>
t (f a) -> f a
asum
      [ [TxOut]
shrAddr
      , [TxOut]
shrVal
      , [TxOut]
shrOutD
      , [TxOut]
shrRefScript
      ]
    where
      shrAddr :: [PLA.TxOut]
      shrAddr :: [TxOut]
shrAddr = Address -> Value -> OutputDatum -> Maybe ScriptHash -> TxOut
PLA.TxOut (Address -> Value -> OutputDatum -> Maybe ScriptHash -> TxOut)
-> [Address] -> [Value -> OutputDatum -> Maybe ScriptHash -> TxOut]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Address -> [Address]
forall a. Arbitrary a => a -> [a]
shrink Address
addr [Value -> OutputDatum -> Maybe ScriptHash -> TxOut]
-> [Value] -> [OutputDatum -> Maybe ScriptHash -> TxOut]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Value -> [Value]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure Value
val [OutputDatum -> Maybe ScriptHash -> TxOut]
-> [OutputDatum] -> [Maybe ScriptHash -> TxOut]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> OutputDatum -> [OutputDatum]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure OutputDatum
outD [Maybe ScriptHash -> TxOut] -> [Maybe ScriptHash] -> [TxOut]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Maybe ScriptHash -> [Maybe ScriptHash]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure Maybe ScriptHash
refScript
      shrVal :: [PLA.TxOut]
      shrVal :: [TxOut]
shrVal = do
        Value.UTxOValue Value
val' <- UTxOValue -> [UTxOValue]
forall a. Arbitrary a => a -> [a]
shrink (Value -> UTxOValue
Value.UTxOValue Value
val)
        TxOut -> [TxOut]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (TxOut -> [TxOut])
-> (Maybe ScriptHash -> TxOut) -> Maybe ScriptHash -> [TxOut]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Address -> Value -> OutputDatum -> Maybe ScriptHash -> TxOut
PLA.TxOut Address
addr Value
val' OutputDatum
outD (Maybe ScriptHash -> [TxOut]) -> Maybe ScriptHash -> [TxOut]
forall a b. (a -> b) -> a -> b
$ Maybe ScriptHash
refScript
      shrOutD :: [PLA.TxOut]
      shrOutD :: [TxOut]
shrOutD = Address -> Value -> OutputDatum -> Maybe ScriptHash -> TxOut
PLA.TxOut Address
addr Value
val (OutputDatum -> Maybe ScriptHash -> TxOut)
-> [OutputDatum] -> [Maybe ScriptHash -> TxOut]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> OutputDatum -> [OutputDatum]
forall a. Arbitrary a => a -> [a]
shrink OutputDatum
outD [Maybe ScriptHash -> TxOut] -> [Maybe ScriptHash] -> [TxOut]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Maybe ScriptHash -> [Maybe ScriptHash]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure Maybe ScriptHash
refScript
      shrRefScript :: [PLA.TxOut]
      shrRefScript :: [TxOut]
shrRefScript = Address -> Value -> OutputDatum -> Maybe ScriptHash -> TxOut
PLA.TxOut Address
addr Value
val OutputDatum
outD (Maybe ScriptHash -> TxOut) -> [Maybe ScriptHash] -> [TxOut]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe ScriptHash -> [Maybe ScriptHash]
forall a. Arbitrary a => a -> [a]
shrink Maybe ScriptHash
refScript

-- | @since 1.4.0
instance CoArbitrary PLA.TxOut where
  {-# INLINEABLE coarbitrary #-}
  coarbitrary :: forall b. TxOut -> Gen b -> Gen b
coarbitrary (PLA.TxOut Address
addr Value
val OutputDatum
outD Maybe ScriptHash
refScript) =
    Address -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. Address -> Gen b -> Gen b
coarbitrary Address
addr
      (Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UTxOValue -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. UTxOValue -> Gen b -> Gen b
coarbitrary (Value -> UTxOValue
Value.UTxOValue Value
val)
      (Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. OutputDatum -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. OutputDatum -> Gen b -> Gen b
coarbitrary OutputDatum
outD
      (Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe ScriptHash -> Gen b -> Gen b
forall b. Maybe ScriptHash -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary Maybe ScriptHash
refScript

-- | @since 1.4.0
instance Function PLA.TxOut where
  {-# INLINEABLE function #-}
  function :: forall b. (TxOut -> b) -> TxOut :-> b
function = (TxOut -> (Address, UTxOValue, OutputDatum, Maybe ScriptHash))
-> ((Address, UTxOValue, OutputDatum, Maybe ScriptHash) -> TxOut)
-> (TxOut -> b)
-> TxOut :-> b
forall b a c.
Function b =>
(a -> b) -> (b -> a) -> (a -> c) -> a :-> c
functionMap TxOut -> (Address, UTxOValue, OutputDatum, Maybe ScriptHash)
into (Address, UTxOValue, OutputDatum, Maybe ScriptHash) -> TxOut
outOf
    where
      into ::
        PLA.TxOut ->
        (PLA.Address, Value.UTxOValue, PLA.OutputDatum, Maybe PLA.ScriptHash)
      into :: TxOut -> (Address, UTxOValue, OutputDatum, Maybe ScriptHash)
into (PLA.TxOut Address
addr Value
val OutputDatum
outD Maybe ScriptHash
refScript) = (Address
addr, Value -> UTxOValue
Value.UTxOValue Value
val, OutputDatum
outD, Maybe ScriptHash
refScript)
      outOf ::
        (PLA.Address, Value.UTxOValue, PLA.OutputDatum, Maybe PLA.ScriptHash) ->
        PLA.TxOut
      outOf :: (Address, UTxOValue, OutputDatum, Maybe ScriptHash) -> TxOut
outOf (Address
addr, Value.UTxOValue Value
val, OutputDatum
outD, Maybe ScriptHash
refScript) = Address -> Value -> OutputDatum -> Maybe ScriptHash -> TxOut
PLA.TxOut Address
addr Value
val OutputDatum
outD Maybe ScriptHash
refScript

-- | @since 1.4.0
instance Arbitrary PLA.AccountBalanceInterval where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen AccountBalanceInterval
arbitrary =
    [Gen AccountBalanceInterval] -> Gen AccountBalanceInterval
forall a. HasCallStack => [Gen a] -> Gen a
oneof
      [ Lovelace -> AccountBalanceInterval
PLA.AccountBalanceLowerBound (Lovelace -> AccountBalanceInterval)
-> Gen Lovelace -> Gen AccountBalanceInterval
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Lovelace
forall a. Arbitrary a => Gen a
arbitrary
      , Lovelace -> AccountBalanceInterval
PLA.AccountBalanceUpperBound (Lovelace -> AccountBalanceInterval)
-> Gen Lovelace -> Gen AccountBalanceInterval
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Lovelace
forall a. Arbitrary a => Gen a
arbitrary
      , do
          Lovelace
lb <- Gen Lovelace
forall a. Arbitrary a => Gen a
arbitrary
          Lovelace
delta <- Positive Lovelace -> Lovelace
forall a. Positive a -> a
getPositive (Positive Lovelace -> Lovelace)
-> Gen (Positive Lovelace) -> Gen Lovelace
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Positive Lovelace)
forall a. Arbitrary a => Gen a
arbitrary
          AccountBalanceInterval -> Gen AccountBalanceInterval
forall a. a -> Gen a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (AccountBalanceInterval -> Gen AccountBalanceInterval)
-> (Lovelace -> AccountBalanceInterval)
-> Lovelace
-> Gen AccountBalanceInterval
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lovelace -> Lovelace -> AccountBalanceInterval
PLA.AccountBalanceBothBounds Lovelace
lb (Lovelace -> Gen AccountBalanceInterval)
-> Lovelace -> Gen AccountBalanceInterval
forall a b. (a -> b) -> a -> b
$ Lovelace
lb Lovelace -> Lovelace -> Lovelace
forall a. Num a => a -> a -> a
+ Lovelace
delta
      , Lovelace -> AccountBalanceInterval
PLA.AccountBalanceExact (Lovelace -> AccountBalanceInterval)
-> Gen Lovelace -> Gen AccountBalanceInterval
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Lovelace
forall a. Arbitrary a => Gen a
arbitrary
      ]
  {-# INLINEABLE shrink #-}
  shrink :: AccountBalanceInterval -> [AccountBalanceInterval]
shrink = \case
    PLA.AccountBalanceLowerBound Lovelace
lb -> Lovelace -> AccountBalanceInterval
PLA.AccountBalanceLowerBound (Lovelace -> AccountBalanceInterval)
-> [Lovelace] -> [AccountBalanceInterval]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Lovelace -> [Lovelace]
forall a. Arbitrary a => a -> [a]
shrink Lovelace
lb
    PLA.AccountBalanceUpperBound Lovelace
ub -> Lovelace -> AccountBalanceInterval
PLA.AccountBalanceUpperBound (Lovelace -> AccountBalanceInterval)
-> [Lovelace] -> [AccountBalanceInterval]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Lovelace -> [Lovelace]
forall a. Arbitrary a => a -> [a]
shrink Lovelace
ub
    PLA.AccountBalanceBothBounds Lovelace
lb Lovelace
ub -> do
      Lovelace
lb' <- Lovelace -> [Lovelace]
forall a. Arbitrary a => a -> [a]
shrink Lovelace
lb
      Lovelace
ub' <- Lovelace -> [Lovelace]
forall a. Arbitrary a => a -> [a]
shrink Lovelace
ub
      Bool -> [()]
forall (f :: Type -> Type). Alternative f => Bool -> f ()
guard (Lovelace
lb Lovelace -> Lovelace -> Bool
forall a. Ord a => a -> a -> Bool
< Lovelace
ub')
      (AccountBalanceInterval -> [AccountBalanceInterval]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (AccountBalanceInterval -> [AccountBalanceInterval])
-> (Lovelace -> AccountBalanceInterval)
-> Lovelace
-> [AccountBalanceInterval]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lovelace -> Lovelace -> AccountBalanceInterval
PLA.AccountBalanceBothBounds Lovelace
lb' (Lovelace -> [AccountBalanceInterval])
-> Lovelace -> [AccountBalanceInterval]
forall a b. (a -> b) -> a -> b
$ Lovelace
ub)
        [AccountBalanceInterval]
-> [AccountBalanceInterval] -> [AccountBalanceInterval]
forall a. [a] -> [a] -> [a]
forall (f :: Type -> Type) a. Alternative f => f a -> f a -> f a
<|> (AccountBalanceInterval -> [AccountBalanceInterval]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (AccountBalanceInterval -> [AccountBalanceInterval])
-> (Lovelace -> AccountBalanceInterval)
-> Lovelace
-> [AccountBalanceInterval]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lovelace -> Lovelace -> AccountBalanceInterval
PLA.AccountBalanceBothBounds Lovelace
lb (Lovelace -> [AccountBalanceInterval])
-> Lovelace -> [AccountBalanceInterval]
forall a b. (a -> b) -> a -> b
$ Lovelace
ub')
    PLA.AccountBalanceExact Lovelace
b -> Lovelace -> AccountBalanceInterval
PLA.AccountBalanceExact (Lovelace -> AccountBalanceInterval)
-> [Lovelace] -> [AccountBalanceInterval]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Lovelace -> [Lovelace]
forall a. Arbitrary a => a -> [a]
shrink Lovelace
b

-- | @since 1.4.0
instance CoArbitrary PLA.AccountBalanceInterval where
  {-# INLINEABLE coarbitrary #-}
  coarbitrary :: forall b. AccountBalanceInterval -> Gen b -> Gen b
coarbitrary = \case
    PLA.AccountBalanceLowerBound Lovelace
lb -> 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
. Lovelace -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. Lovelace -> Gen b -> Gen b
coarbitrary Lovelace
lb
    PLA.AccountBalanceUpperBound Lovelace
ub -> 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
. Lovelace -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. Lovelace -> Gen b -> Gen b
coarbitrary Lovelace
ub
    PLA.AccountBalanceBothBounds Lovelace
lb Lovelace
ub -> 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
. Lovelace -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. Lovelace -> Gen b -> Gen b
coarbitrary Lovelace
lb (Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Lovelace -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. Lovelace -> Gen b -> Gen b
coarbitrary Lovelace
ub
    PLA.AccountBalanceExact Lovelace
b -> 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
. Lovelace -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. Lovelace -> Gen b -> Gen b
coarbitrary Lovelace
b

-- | @since 1.4.0
instance Function PLA.AccountBalanceInterval where
  {-# INLINEABLE function #-}
  function :: forall b.
(AccountBalanceInterval -> b) -> AccountBalanceInterval :-> b
function = (AccountBalanceInterval
 -> Either Lovelace (These Lovelace Lovelace))
-> (Either Lovelace (These Lovelace Lovelace)
    -> AccountBalanceInterval)
-> (AccountBalanceInterval -> b)
-> AccountBalanceInterval :-> b
forall b a c.
Function b =>
(a -> b) -> (b -> a) -> (a -> c) -> a :-> c
functionMap AccountBalanceInterval -> Either Lovelace (These Lovelace Lovelace)
into Either Lovelace (These Lovelace Lovelace) -> AccountBalanceInterval
outOf
    where
      into :: PLA.AccountBalanceInterval -> Either PLA.Lovelace (These PLA.Lovelace PLA.Lovelace)
      into :: AccountBalanceInterval -> Either Lovelace (These Lovelace Lovelace)
into = \case
        PLA.AccountBalanceLowerBound Lovelace
lb -> These Lovelace Lovelace
-> Either Lovelace (These Lovelace Lovelace)
forall a b. b -> Either a b
Right (Lovelace -> These Lovelace Lovelace
forall a b. a -> These a b
This Lovelace
lb)
        PLA.AccountBalanceUpperBound Lovelace
ub -> These Lovelace Lovelace
-> Either Lovelace (These Lovelace Lovelace)
forall a b. b -> Either a b
Right (Lovelace -> These Lovelace Lovelace
forall a b. b -> These a b
That Lovelace
ub)
        PLA.AccountBalanceBothBounds Lovelace
lb Lovelace
ub -> These Lovelace Lovelace
-> Either Lovelace (These Lovelace Lovelace)
forall a b. b -> Either a b
Right (Lovelace -> Lovelace -> These Lovelace Lovelace
forall a b. a -> b -> These a b
These Lovelace
lb Lovelace
ub)
        PLA.AccountBalanceExact Lovelace
b -> Lovelace -> Either Lovelace (These Lovelace Lovelace)
forall a b. a -> Either a b
Left Lovelace
b
      outOf ::
        Either PLA.Lovelace (These PLA.Lovelace PLA.Lovelace) ->
        PLA.AccountBalanceInterval
      outOf :: Either Lovelace (These Lovelace Lovelace) -> AccountBalanceInterval
outOf = \case
        Left Lovelace
b -> Lovelace -> AccountBalanceInterval
PLA.AccountBalanceExact Lovelace
b
        Right These Lovelace Lovelace
x -> (Lovelace -> AccountBalanceInterval)
-> (Lovelace -> AccountBalanceInterval)
-> (Lovelace -> Lovelace -> AccountBalanceInterval)
-> These Lovelace Lovelace
-> AccountBalanceInterval
forall a c b.
(a -> c) -> (b -> c) -> (a -> b -> c) -> These a b -> c
these Lovelace -> AccountBalanceInterval
PLA.AccountBalanceLowerBound Lovelace -> AccountBalanceInterval
PLA.AccountBalanceUpperBound Lovelace -> Lovelace -> AccountBalanceInterval
PLA.AccountBalanceBothBounds These Lovelace Lovelace
x

-- | @since 1.4.0
deriving via
  (PLA.Map PLA.AccountId PLA.AccountBalanceInterval)
  instance
    Arbitrary PLA.AccountBalanceIntervals

-- | @since 1.4.0
deriving via
  (PLA.Map PLA.AccountId PLA.AccountBalanceInterval)
  instance
    CoArbitrary PLA.AccountBalanceIntervals

-- | @since 1.4.0
instance Function PLA.AccountBalanceIntervals where
  {-# INLINEABLE function #-}
  function :: forall b.
(AccountBalanceIntervals -> b) -> AccountBalanceIntervals :-> b
function = (AccountBalanceIntervals -> Map AccountId AccountBalanceInterval)
-> (Map AccountId AccountBalanceInterval
    -> AccountBalanceIntervals)
-> (AccountBalanceIntervals -> b)
-> AccountBalanceIntervals :-> b
forall b a c.
Function b =>
(a -> b) -> (b -> a) -> (a -> c) -> a :-> c
functionMap AccountBalanceIntervals -> Map AccountId AccountBalanceInterval
forall a b. Coercible a b => a -> b
coerce Map AccountId AccountBalanceInterval -> AccountBalanceIntervals
PLA.AccountBalanceIntervals

-- | @since 1.4.0
instance Arbitrary PLA.TxCert where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen TxCert
arbitrary =
    [Gen TxCert] -> Gen TxCert
forall a. HasCallStack => [Gen a] -> Gen a
oneof
      [ AccountId -> Lovelace -> TxCert
PLA.TxCertRegAccount (AccountId -> Lovelace -> TxCert)
-> Gen AccountId -> Gen (Lovelace -> TxCert)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen AccountId
forall a. Arbitrary a => Gen a
arbitrary Gen (Lovelace -> TxCert) -> Gen Lovelace -> Gen TxCert
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 Lovelace
forall a. Arbitrary a => Gen a
arbitrary
      , AccountId -> Lovelace -> TxCert
PLA.TxCertUnRegAccount (AccountId -> Lovelace -> TxCert)
-> Gen AccountId -> Gen (Lovelace -> TxCert)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen AccountId
forall a. Arbitrary a => Gen a
arbitrary Gen (Lovelace -> TxCert) -> Gen Lovelace -> Gen TxCert
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 Lovelace
forall a. Arbitrary a => Gen a
arbitrary
      , AccountId -> Delegatee -> TxCert
PLA.TxCertDelegAccount (AccountId -> Delegatee -> TxCert)
-> Gen AccountId -> Gen (Delegatee -> TxCert)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen AccountId
forall a. Arbitrary a => Gen a
arbitrary Gen (Delegatee -> TxCert) -> Gen Delegatee -> Gen TxCert
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 Delegatee
forall a. Arbitrary a => Gen a
arbitrary
      , AccountId -> Delegatee -> Lovelace -> TxCert
PLA.TxCertRegAccountDeleg (AccountId -> Delegatee -> Lovelace -> TxCert)
-> Gen AccountId -> Gen (Delegatee -> Lovelace -> TxCert)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen AccountId
forall a. Arbitrary a => Gen a
arbitrary Gen (Delegatee -> Lovelace -> TxCert)
-> Gen Delegatee -> Gen (Lovelace -> TxCert)
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 Delegatee
forall a. Arbitrary a => Gen a
arbitrary Gen (Lovelace -> TxCert) -> Gen Lovelace -> Gen TxCert
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 Lovelace
forall a. Arbitrary a => Gen a
arbitrary
      , DRepCredential -> Lovelace -> TxCert
PLA.TxCertRegDRep (DRepCredential -> Lovelace -> TxCert)
-> Gen DRepCredential -> Gen (Lovelace -> TxCert)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen DRepCredential
forall a. Arbitrary a => Gen a
arbitrary Gen (Lovelace -> TxCert) -> Gen Lovelace -> Gen TxCert
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 Lovelace
forall a. Arbitrary a => Gen a
arbitrary
      , DRepCredential -> TxCert
PLA.TxCertUpdateDRep (DRepCredential -> TxCert) -> Gen DRepCredential -> Gen TxCert
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen DRepCredential
forall a. Arbitrary a => Gen a
arbitrary
      , DRepCredential -> Lovelace -> TxCert
PLA.TxCertUnRegDRep (DRepCredential -> Lovelace -> TxCert)
-> Gen DRepCredential -> Gen (Lovelace -> TxCert)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen DRepCredential
forall a. Arbitrary a => Gen a
arbitrary Gen (Lovelace -> TxCert) -> Gen Lovelace -> Gen TxCert
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 Lovelace
forall a. Arbitrary a => Gen a
arbitrary
      , PubKeyHash -> PubKeyHash -> TxCert
PLA.TxCertPoolRegister (PubKeyHash -> PubKeyHash -> TxCert)
-> Gen PubKeyHash -> Gen (PubKeyHash -> TxCert)
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 -> TxCert) -> Gen PubKeyHash -> Gen TxCert
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 -> TxCert
PLA.TxCertPoolRetire (PubKeyHash -> Integer -> TxCert)
-> Gen PubKeyHash -> Gen (Integer -> TxCert)
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 -> TxCert) -> Gen Integer -> Gen TxCert
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 Integer
forall a. Arbitrary a => Gen a
arbitrary
      , ColdCommitteeCredential -> HotCommitteeCredential -> TxCert
PLA.TxCertAuthHotCommittee (ColdCommitteeCredential -> HotCommitteeCredential -> TxCert)
-> Gen ColdCommitteeCredential
-> Gen (HotCommitteeCredential -> TxCert)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ColdCommitteeCredential
forall a. Arbitrary a => Gen a
arbitrary Gen (HotCommitteeCredential -> TxCert)
-> Gen HotCommitteeCredential -> Gen TxCert
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 HotCommitteeCredential
forall a. Arbitrary a => Gen a
arbitrary
      , ColdCommitteeCredential -> TxCert
PLA.TxCertResignColdCommittee (ColdCommitteeCredential -> TxCert)
-> Gen ColdCommitteeCredential -> Gen TxCert
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ColdCommitteeCredential
forall a. Arbitrary a => Gen a
arbitrary
      ]
  {-# INLINEABLE shrink #-}
  shrink :: TxCert -> [TxCert]
shrink = \case
    PLA.TxCertRegAccount AccountId
aid Lovelace
ll -> AccountId -> Lovelace -> TxCert
PLA.TxCertRegAccount AccountId
aid (Lovelace -> TxCert) -> [Lovelace] -> [TxCert]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Lovelace -> [Lovelace]
forall a. Arbitrary a => a -> [a]
shrink Lovelace
ll
    PLA.TxCertUnRegAccount AccountId
aid Lovelace
ll -> AccountId -> Lovelace -> TxCert
PLA.TxCertUnRegAccount AccountId
aid (Lovelace -> TxCert) -> [Lovelace] -> [TxCert]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Lovelace -> [Lovelace]
forall a. Arbitrary a => a -> [a]
shrink Lovelace
ll
    PLA.TxCertDelegAccount AccountId
_ Delegatee
_ -> []
    PLA.TxCertRegAccountDeleg AccountId
aid Delegatee
d Lovelace
ll -> AccountId -> Delegatee -> Lovelace -> TxCert
PLA.TxCertRegAccountDeleg AccountId
aid Delegatee
d (Lovelace -> TxCert) -> [Lovelace] -> [TxCert]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Lovelace -> [Lovelace]
forall a. Arbitrary a => a -> [a]
shrink Lovelace
ll
    PLA.TxCertRegDRep DRepCredential
cred Lovelace
ll -> DRepCredential -> Lovelace -> TxCert
PLA.TxCertRegDRep DRepCredential
cred (Lovelace -> TxCert) -> [Lovelace] -> [TxCert]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Lovelace -> [Lovelace]
forall a. Arbitrary a => a -> [a]
shrink Lovelace
ll
    PLA.TxCertUpdateDRep DRepCredential
_ -> []
    PLA.TxCertUnRegDRep DRepCredential
cred Lovelace
ll -> DRepCredential -> Lovelace -> TxCert
PLA.TxCertUnRegDRep DRepCredential
cred (Lovelace -> TxCert) -> [Lovelace] -> [TxCert]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Lovelace -> [Lovelace]
forall a. Arbitrary a => a -> [a]
shrink Lovelace
ll
    PLA.TxCertPoolRegister PubKeyHash
_ PubKeyHash
_ -> []
    PLA.TxCertPoolRetire PubKeyHash
pkh Integer
i -> PubKeyHash -> Integer -> TxCert
PLA.TxCertPoolRetire PubKeyHash
pkh (Integer -> TxCert) -> [Integer] -> [TxCert]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Integer -> [Integer]
forall a. Arbitrary a => a -> [a]
shrink Integer
i
    PLA.TxCertAuthHotCommittee ColdCommitteeCredential
_ HotCommitteeCredential
_ -> []
    PLA.TxCertResignColdCommittee ColdCommitteeCredential
_ -> []

-- TODO: CoArbitrary, Function

-- | @since 1.4.0
instance Arbitrary PLA.TxOutRef where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen TxOutRef
arbitrary = do
    TxId
refId <- Gen TxId
forall a. Arbitrary a => Gen a
arbitrary
    Integer
refIdX <- NonNegative Integer -> Integer
forall a. NonNegative a -> a
getNonNegative (NonNegative Integer -> Integer)
-> Gen (NonNegative Integer) -> Gen Integer
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (NonNegative Integer)
forall a. Arbitrary a => Gen a
arbitrary
    TxOutRef -> Gen TxOutRef
forall a. a -> Gen a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (TxOutRef -> Gen TxOutRef)
-> (Integer -> TxOutRef) -> Integer -> Gen TxOutRef
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxId -> Integer -> TxOutRef
PLA.TxOutRef TxId
refId (Integer -> Gen TxOutRef) -> Integer -> Gen TxOutRef
forall a b. (a -> b) -> a -> b
$ Integer
refIdX
  shrink :: TxOutRef -> [TxOutRef]
shrink (PLA.TxOutRef TxId
tid Integer
ix) =
    TxId -> Integer -> TxOutRef
PLA.TxOutRef TxId
tid (Integer -> TxOutRef) -> [Integer] -> [TxOutRef]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> ((NonNegative Integer -> Integer)
-> [NonNegative Integer] -> [Integer]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
fmap NonNegative Integer -> Integer
forall a. NonNegative a -> a
getNonNegative ([NonNegative Integer] -> [Integer])
-> (Integer -> [NonNegative Integer]) -> Integer -> [Integer]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonNegative Integer -> [NonNegative Integer]
forall a. Arbitrary a => a -> [a]
shrink (NonNegative Integer -> [NonNegative Integer])
-> (Integer -> NonNegative Integer)
-> Integer
-> [NonNegative Integer]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> NonNegative Integer
forall a. a -> NonNegative a
NonNegative (Integer -> [Integer]) -> Integer -> [Integer]
forall a b. (a -> b) -> a -> b
$ Integer
ix)

-- TODO: CoArbitrary, Function

-- | @since 1.4.0
instance Arbitrary PLA.TxInInfo where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen TxInInfo
arbitrary = TxOutRef -> TxOut -> TxInInfo
PLA.TxInInfo (TxOutRef -> TxOut -> TxInInfo)
-> Gen TxOutRef -> Gen (TxOut -> TxInInfo)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen TxOutRef
forall a. Arbitrary a => Gen a
arbitrary Gen (TxOut -> TxInInfo) -> Gen TxOut -> Gen TxInInfo
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 TxOut
forall a. Arbitrary a => Gen a
arbitrary
  {-# INLINEABLE shrink #-}
  shrink :: TxInInfo -> [TxInInfo]
shrink (PLA.TxInInfo TxOutRef
outRef TxOut
resolved) = do
    TxOutRef
outRef' <- TxOutRef -> [TxOutRef]
forall a. Arbitrary a => a -> [a]
shrink TxOutRef
outRef
    TxOut
resolved' <- TxOut -> [TxOut]
forall a. Arbitrary a => a -> [a]
shrink TxOut
resolved
    (TxInInfo -> [TxInInfo]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (TxInInfo -> [TxInInfo])
-> (TxOut -> TxInInfo) -> TxOut -> [TxInInfo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxOutRef -> TxOut -> TxInInfo
PLA.TxInInfo TxOutRef
outRef (TxOut -> [TxInInfo]) -> TxOut -> [TxInInfo]
forall a b. (a -> b) -> a -> b
$ TxOut
resolved')
      [TxInInfo] -> [TxInInfo] -> [TxInInfo]
forall a. [a] -> [a] -> [a]
forall (f :: Type -> Type) a. Alternative f => f a -> f a -> f a
<|> (TxInInfo -> [TxInInfo]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (TxInInfo -> [TxInInfo])
-> (TxOut -> TxInInfo) -> TxOut -> [TxInInfo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxOutRef -> TxOut -> TxInInfo
PLA.TxInInfo TxOutRef
outRef' (TxOut -> [TxInInfo]) -> TxOut -> [TxInInfo]
forall a b. (a -> b) -> a -> b
$ TxOut
resolved)

-- | @since 1.4.0
instance Arbitrary PLA.ProtocolVersion where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen ProtocolVersion
arbitrary = do
    NonNegative Integer
major <- Gen (NonNegative Integer)
forall a. Arbitrary a => Gen a
arbitrary
    NonNegative Integer
minor <- Gen (NonNegative Integer)
forall a. Arbitrary a => Gen a
arbitrary
    ProtocolVersion -> Gen ProtocolVersion
forall a. a -> Gen a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (ProtocolVersion -> Gen ProtocolVersion)
-> (Integer -> ProtocolVersion) -> Integer -> Gen ProtocolVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer -> ProtocolVersion
PLA.ProtocolVersion Integer
major (Integer -> Gen ProtocolVersion) -> Integer -> Gen ProtocolVersion
forall a b. (a -> b) -> a -> b
$ Integer
minor
  {-# INLINEABLE shrink #-}
  shrink :: ProtocolVersion -> [ProtocolVersion]
shrink (PLA.ProtocolVersion Integer
major Integer
minor) = do
    NonNegative Integer
major' <- NonNegative Integer -> [NonNegative Integer]
forall a. Arbitrary a => a -> [a]
shrink (Integer -> NonNegative Integer
forall a. a -> NonNegative a
NonNegative Integer
major)
    NonNegative Integer
minor' <- NonNegative Integer -> [NonNegative Integer]
forall a. Arbitrary a => a -> [a]
shrink (Integer -> NonNegative Integer
forall a. a -> NonNegative a
NonNegative Integer
minor)
    ProtocolVersion -> [ProtocolVersion]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (ProtocolVersion -> [ProtocolVersion])
-> (Integer -> ProtocolVersion) -> Integer -> [ProtocolVersion]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Integer -> ProtocolVersion
PLA.ProtocolVersion Integer
major' (Integer -> [ProtocolVersion]) -> Integer -> [ProtocolVersion]
forall a b. (a -> b) -> a -> b
$ Integer
minor'

-- | @since 1.4.0
instance Arbitrary PLA.GovernanceActionId where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen GovernanceActionId
arbitrary =
    TxId -> Integer -> GovernanceActionId
PLA.GovernanceActionId
      (TxId -> Integer -> GovernanceActionId)
-> Gen TxId -> Gen (Integer -> GovernanceActionId)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen TxId
forall a. Arbitrary a => Gen a
arbitrary
      Gen (Integer -> GovernanceActionId)
-> Gen Integer -> Gen GovernanceActionId
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
<*> (NonNegative Integer -> Integer
forall a. NonNegative a -> a
getNonNegative (NonNegative Integer -> Integer)
-> Gen (NonNegative Integer) -> Gen Integer
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (NonNegative Integer)
forall a. Arbitrary a => Gen a
arbitrary)
  {-# INLINEABLE shrink #-}
  shrink :: GovernanceActionId -> [GovernanceActionId]
shrink (PLA.GovernanceActionId TxId
tid Integer
ix) =
    -- Hashes don't shrink, so we don't bother either
    TxId -> Integer -> GovernanceActionId
PLA.GovernanceActionId TxId
tid (Integer -> GovernanceActionId)
-> (NonNegative Integer -> Integer)
-> NonNegative Integer
-> GovernanceActionId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonNegative Integer -> Integer
forall a. NonNegative a -> a
getNonNegative (NonNegative Integer -> GovernanceActionId)
-> [NonNegative Integer] -> [GovernanceActionId]
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
ix)

-- | @since 1.4.0
deriving via (Maybe PLA.ScriptHash) instance Arbitrary PLA.Constitution

-- | @since 1.4.0
deriving via (Maybe PLA.ScriptHash) instance CoArbitrary PLA.Constitution

-- | @since 1.4.0
instance Function PLA.Constitution where
  {-# INLINEABLE function #-}
  function :: forall b. (Constitution -> b) -> Constitution :-> b
function = (Constitution -> Maybe ScriptHash)
-> (Maybe ScriptHash -> Constitution)
-> (Constitution -> b)
-> Constitution :-> b
forall b a c.
Function b =>
(a -> b) -> (b -> a) -> (a -> c) -> a :-> c
functionMap Constitution -> Maybe ScriptHash
forall a b. Coercible a b => a -> b
coerce Maybe ScriptHash -> Constitution
PLA.Constitution

-- | @since 1.4.0
instance Arbitrary PLA.GovernanceAction where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen GovernanceAction
arbitrary =
    [Gen GovernanceAction] -> Gen GovernanceAction
forall a. HasCallStack => [Gen a] -> Gen a
oneof
      [ Maybe GovernanceActionId
-> ChangedParameters -> Maybe ScriptHash -> GovernanceAction
PLA.ParameterChange (Maybe GovernanceActionId
 -> ChangedParameters -> Maybe ScriptHash -> GovernanceAction)
-> Gen (Maybe GovernanceActionId)
-> Gen (ChangedParameters -> Maybe ScriptHash -> GovernanceAction)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Maybe GovernanceActionId)
forall a. Arbitrary a => Gen a
arbitrary Gen (ChangedParameters -> Maybe ScriptHash -> GovernanceAction)
-> Gen ChangedParameters
-> Gen (Maybe ScriptHash -> GovernanceAction)
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 ChangedParameters
forall a. Arbitrary a => Gen a
arbitrary Gen (Maybe ScriptHash -> GovernanceAction)
-> Gen (Maybe ScriptHash) -> Gen GovernanceAction
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 (Maybe ScriptHash)
forall a. Arbitrary a => Gen a
arbitrary
      , Maybe GovernanceActionId -> ProtocolVersion -> GovernanceAction
PLA.HardForkInitiation (Maybe GovernanceActionId -> ProtocolVersion -> GovernanceAction)
-> Gen (Maybe GovernanceActionId)
-> Gen (ProtocolVersion -> GovernanceAction)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Maybe GovernanceActionId)
forall a. Arbitrary a => Gen a
arbitrary Gen (ProtocolVersion -> GovernanceAction)
-> Gen ProtocolVersion -> Gen GovernanceAction
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 ProtocolVersion
forall a. Arbitrary a => Gen a
arbitrary
      , Map Credential Lovelace -> Maybe ScriptHash -> GovernanceAction
PLA.TreasuryWithdrawals (Map Credential Lovelace -> Maybe ScriptHash -> GovernanceAction)
-> Gen (Map Credential Lovelace)
-> Gen (Maybe ScriptHash -> GovernanceAction)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Map Credential Lovelace)
forall a. Arbitrary a => Gen a
arbitrary Gen (Maybe ScriptHash -> GovernanceAction)
-> Gen (Maybe ScriptHash) -> Gen GovernanceAction
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 (Maybe ScriptHash)
forall a. Arbitrary a => Gen a
arbitrary
      , Maybe GovernanceActionId -> GovernanceAction
PLA.NoConfidence (Maybe GovernanceActionId -> GovernanceAction)
-> Gen (Maybe GovernanceActionId) -> Gen GovernanceAction
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Maybe GovernanceActionId)
forall a. Arbitrary a => Gen a
arbitrary
      , Maybe GovernanceActionId
-> [ColdCommitteeCredential]
-> Map ColdCommitteeCredential Integer
-> Rational
-> GovernanceAction
PLA.UpdateCommittee
          (Maybe GovernanceActionId
 -> [ColdCommitteeCredential]
 -> Map ColdCommitteeCredential Integer
 -> Rational
 -> GovernanceAction)
-> Gen (Maybe GovernanceActionId)
-> Gen
     ([ColdCommitteeCredential]
      -> Map ColdCommitteeCredential Integer
      -> Rational
      -> GovernanceAction)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Maybe GovernanceActionId)
forall a. Arbitrary a => Gen a
arbitrary
          Gen
  ([ColdCommitteeCredential]
   -> Map ColdCommitteeCredential Integer
   -> Rational
   -> GovernanceAction)
-> Gen [ColdCommitteeCredential]
-> Gen
     (Map ColdCommitteeCredential Integer
      -> Rational -> GovernanceAction)
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 [ColdCommitteeCredential]
forall a. Arbitrary a => Gen a
arbitrary
          Gen
  (Map ColdCommitteeCredential Integer
   -> Rational -> GovernanceAction)
-> Gen (Map ColdCommitteeCredential Integer)
-> Gen (Rational -> GovernanceAction)
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 (Map ColdCommitteeCredential Integer)
forall a. Arbitrary a => Gen a
arbitrary
          Gen (Rational -> GovernanceAction)
-> Gen Rational -> Gen GovernanceAction
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
<*> (Integer -> Integer -> Rational
PLA.unsafeRatio (Integer -> Integer -> Rational)
-> (Int -> Integer) -> Int -> Integer -> Rational
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Integer -> Rational)
-> Gen Int -> Gen (Integer -> Rational)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> (Int, Int) -> Gen Int
chooseInt (Int
1, Int
100) Gen (Integer -> Rational) -> Gen Integer -> Gen Rational
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
<*> Integer -> Gen Integer
forall a. a -> Gen a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure Integer
100)
      , Maybe GovernanceActionId -> Constitution -> GovernanceAction
PLA.NewConstitution (Maybe GovernanceActionId -> Constitution -> GovernanceAction)
-> Gen (Maybe GovernanceActionId)
-> Gen (Constitution -> GovernanceAction)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Maybe GovernanceActionId)
forall a. Arbitrary a => Gen a
arbitrary Gen (Constitution -> GovernanceAction)
-> Gen Constitution -> Gen GovernanceAction
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 Constitution
forall a. Arbitrary a => Gen a
arbitrary
      , GovernanceAction -> Gen GovernanceAction
forall a. a -> Gen a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure GovernanceAction
PLA.InfoAction
      ]
  {-# INLINEABLE shrink #-}
  shrink :: GovernanceAction -> [GovernanceAction]
shrink = \case
    PLA.ParameterChange Maybe GovernanceActionId
mgid ChangedParameters
cp Maybe ScriptHash
msh ->
      Maybe GovernanceActionId
-> ChangedParameters -> Maybe ScriptHash -> GovernanceAction
PLA.ParameterChange
        (Maybe GovernanceActionId
 -> ChangedParameters -> Maybe ScriptHash -> GovernanceAction)
-> [Maybe GovernanceActionId]
-> [ChangedParameters -> Maybe ScriptHash -> GovernanceAction]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe GovernanceActionId -> [Maybe GovernanceActionId]
forall a. Arbitrary a => a -> [a]
shrink Maybe GovernanceActionId
mgid
        [ChangedParameters -> Maybe ScriptHash -> GovernanceAction]
-> [ChangedParameters] -> [Maybe ScriptHash -> GovernanceAction]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> ChangedParameters -> [ChangedParameters]
forall a. Arbitrary a => a -> [a]
shrink ChangedParameters
cp
        [Maybe ScriptHash -> GovernanceAction]
-> [Maybe ScriptHash] -> [GovernanceAction]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Maybe ScriptHash -> [Maybe ScriptHash]
forall a. Arbitrary a => a -> [a]
shrink Maybe ScriptHash
msh
    PLA.HardForkInitiation Maybe GovernanceActionId
mgid ProtocolVersion
v ->
      Maybe GovernanceActionId -> ProtocolVersion -> GovernanceAction
PLA.HardForkInitiation
        (Maybe GovernanceActionId -> ProtocolVersion -> GovernanceAction)
-> [Maybe GovernanceActionId]
-> [ProtocolVersion -> GovernanceAction]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe GovernanceActionId -> [Maybe GovernanceActionId]
forall a. Arbitrary a => a -> [a]
shrink Maybe GovernanceActionId
mgid
        [ProtocolVersion -> GovernanceAction]
-> [ProtocolVersion] -> [GovernanceAction]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> ProtocolVersion -> [ProtocolVersion]
forall a. Arbitrary a => a -> [a]
shrink ProtocolVersion
v
    PLA.TreasuryWithdrawals Map Credential Lovelace
wdrls Maybe ScriptHash
msh ->
      Map Credential Lovelace -> Maybe ScriptHash -> GovernanceAction
PLA.TreasuryWithdrawals
        (Map Credential Lovelace -> Maybe ScriptHash -> GovernanceAction)
-> [Map Credential Lovelace]
-> [Maybe ScriptHash -> GovernanceAction]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Map Credential Lovelace -> [Map Credential Lovelace]
forall a. Arbitrary a => a -> [a]
shrink Map Credential Lovelace
wdrls
        [Maybe ScriptHash -> GovernanceAction]
-> [Maybe ScriptHash] -> [GovernanceAction]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Maybe ScriptHash -> [Maybe ScriptHash]
forall a. Arbitrary a => a -> [a]
shrink Maybe ScriptHash
msh
    PLA.NoConfidence Maybe GovernanceActionId
msh -> Maybe GovernanceActionId -> GovernanceAction
PLA.NoConfidence (Maybe GovernanceActionId -> GovernanceAction)
-> [Maybe GovernanceActionId] -> [GovernanceAction]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe GovernanceActionId -> [Maybe GovernanceActionId]
forall a. Arbitrary a => a -> [a]
shrink Maybe GovernanceActionId
msh
    -- No quorum shrinking
    PLA.UpdateCommittee Maybe GovernanceActionId
mgid [ColdCommitteeCredential]
creds Map ColdCommitteeCredential Integer
mems Rational
quorum -> do
      Maybe GovernanceActionId
mgid' <- Maybe GovernanceActionId -> [Maybe GovernanceActionId]
forall a. Arbitrary a => a -> [a]
shrink Maybe GovernanceActionId
mgid
      [ColdCommitteeCredential]
creds' <- [ColdCommitteeCredential] -> [[ColdCommitteeCredential]]
forall a. Arbitrary a => a -> [a]
shrink [ColdCommitteeCredential]
creds
      Map ColdCommitteeCredential Integer
mems' <- Map ColdCommitteeCredential Integer
-> [Map ColdCommitteeCredential Integer]
forall a. Arbitrary a => a -> [a]
shrink Map ColdCommitteeCredential Integer
mems
      GovernanceAction -> [GovernanceAction]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (GovernanceAction -> [GovernanceAction])
-> (Rational -> GovernanceAction) -> Rational -> [GovernanceAction]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe GovernanceActionId
-> [ColdCommitteeCredential]
-> Map ColdCommitteeCredential Integer
-> Rational
-> GovernanceAction
PLA.UpdateCommittee Maybe GovernanceActionId
mgid' [ColdCommitteeCredential]
creds' Map ColdCommitteeCredential Integer
mems' (Rational -> [GovernanceAction]) -> Rational -> [GovernanceAction]
forall a b. (a -> b) -> a -> b
$ Rational
quorum
    PLA.NewConstitution Maybe GovernanceActionId
mgid Constitution
c -> Maybe GovernanceActionId -> Constitution -> GovernanceAction
PLA.NewConstitution (Maybe GovernanceActionId -> Constitution -> GovernanceAction)
-> [Maybe GovernanceActionId] -> [Constitution -> GovernanceAction]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe GovernanceActionId -> [Maybe GovernanceActionId]
forall a. Arbitrary a => a -> [a]
shrink Maybe GovernanceActionId
mgid [Constitution -> GovernanceAction]
-> [Constitution] -> [GovernanceAction]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Constitution -> [Constitution]
forall a. Arbitrary a => a -> [a]
shrink Constitution
c
    GovernanceAction
_ -> []

-- | @since 1.4.0
instance Arbitrary PLA.ProposalProcedure where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen ProposalProcedure
arbitrary = Lovelace -> Credential -> GovernanceAction -> ProposalProcedure
PLA.ProposalProcedure (Lovelace -> Credential -> GovernanceAction -> ProposalProcedure)
-> Gen Lovelace
-> Gen (Credential -> GovernanceAction -> ProposalProcedure)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Lovelace
forall a. Arbitrary a => Gen a
arbitrary Gen (Credential -> GovernanceAction -> ProposalProcedure)
-> Gen Credential -> Gen (GovernanceAction -> ProposalProcedure)
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 Credential
forall a. Arbitrary a => Gen a
arbitrary Gen (GovernanceAction -> ProposalProcedure)
-> Gen GovernanceAction -> Gen ProposalProcedure
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 GovernanceAction
forall a. Arbitrary a => Gen a
arbitrary
  {-# INLINEABLE shrink #-}
  shrink :: ProposalProcedure -> [ProposalProcedure]
shrink (PLA.ProposalProcedure Lovelace
dep Credential
raddr GovernanceAction
ga) =
    Lovelace -> Credential -> GovernanceAction -> ProposalProcedure
PLA.ProposalProcedure (Lovelace -> Credential -> GovernanceAction -> ProposalProcedure)
-> [Lovelace]
-> [Credential -> GovernanceAction -> ProposalProcedure]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Lovelace -> [Lovelace]
forall a. Arbitrary a => a -> [a]
shrink Lovelace
dep [Credential -> GovernanceAction -> ProposalProcedure]
-> [Credential] -> [GovernanceAction -> ProposalProcedure]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Credential -> [Credential]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure Credential
raddr [GovernanceAction -> ProposalProcedure]
-> [GovernanceAction] -> [ProposalProcedure]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> GovernanceAction -> [GovernanceAction]
forall a. Arbitrary a => a -> [a]
shrink GovernanceAction
ga

-- | @since 1.4.0
instance Arbitrary PLA.ScriptPurpose where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen ScriptPurpose
arbitrary =
    [Gen ScriptPurpose] -> Gen ScriptPurpose
forall a. HasCallStack => [Gen a] -> Gen a
oneof
      [ ScriptHash -> CurrencySymbol -> ScriptPurpose
PLA.Minting (ScriptHash -> CurrencySymbol -> ScriptPurpose)
-> Gen ScriptHash -> Gen (CurrencySymbol -> ScriptPurpose)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ScriptHash
forall a. Arbitrary a => Gen a
arbitrary Gen (CurrencySymbol -> ScriptPurpose)
-> Gen CurrencySymbol -> Gen ScriptPurpose
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 CurrencySymbol
forall a. Arbitrary a => Gen a
arbitrary
      , ScriptHash -> TxOutRef -> ScriptPurpose
PLA.Spending (ScriptHash -> TxOutRef -> ScriptPurpose)
-> Gen ScriptHash -> Gen (TxOutRef -> ScriptPurpose)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ScriptHash
forall a. Arbitrary a => Gen a
arbitrary Gen (TxOutRef -> ScriptPurpose)
-> Gen TxOutRef -> Gen ScriptPurpose
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 TxOutRef
forall a. Arbitrary a => Gen a
arbitrary
      , ScriptHash -> Credential -> ScriptPurpose
PLA.Withdrawing (ScriptHash -> Credential -> ScriptPurpose)
-> Gen ScriptHash -> Gen (Credential -> ScriptPurpose)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ScriptHash
forall a. Arbitrary a => Gen a
arbitrary Gen (Credential -> ScriptPurpose)
-> Gen Credential -> Gen ScriptPurpose
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 Credential
forall a. Arbitrary a => Gen a
arbitrary
      , ScriptHash -> Integer -> TxCert -> ScriptPurpose
PLA.Certifying (ScriptHash -> Integer -> TxCert -> ScriptPurpose)
-> Gen ScriptHash -> Gen (Integer -> TxCert -> ScriptPurpose)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ScriptHash
forall a. Arbitrary a => Gen a
arbitrary Gen (Integer -> TxCert -> ScriptPurpose)
-> Gen Integer -> Gen (TxCert -> ScriptPurpose)
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 Integer
forall a. Arbitrary a => Gen a
arbitrary Gen (TxCert -> ScriptPurpose) -> Gen TxCert -> Gen ScriptPurpose
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 TxCert
forall a. Arbitrary a => Gen a
arbitrary
      , ScriptHash -> Voter -> ScriptPurpose
PLA.Voting (ScriptHash -> Voter -> ScriptPurpose)
-> Gen ScriptHash -> Gen (Voter -> ScriptPurpose)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ScriptHash
forall a. Arbitrary a => Gen a
arbitrary Gen (Voter -> ScriptPurpose) -> Gen Voter -> Gen ScriptPurpose
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 Voter
forall a. Arbitrary a => Gen a
arbitrary
      , ScriptHash -> Integer -> ProposalProcedure -> ScriptPurpose
PLA.Proposing (ScriptHash -> Integer -> ProposalProcedure -> ScriptPurpose)
-> Gen ScriptHash
-> Gen (Integer -> ProposalProcedure -> ScriptPurpose)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ScriptHash
forall a. Arbitrary a => Gen a
arbitrary Gen (Integer -> ProposalProcedure -> ScriptPurpose)
-> Gen Integer -> Gen (ProposalProcedure -> ScriptPurpose)
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 Integer
forall a. Arbitrary a => Gen a
arbitrary Gen (ProposalProcedure -> ScriptPurpose)
-> Gen ProposalProcedure -> Gen ScriptPurpose
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 ProposalProcedure
forall a. Arbitrary a => Gen a
arbitrary
      , ScriptHash -> Integer -> ScriptPurpose
PLA.Guarding (ScriptHash -> Integer -> ScriptPurpose)
-> Gen ScriptHash -> Gen (Integer -> ScriptPurpose)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen ScriptHash
forall a. Arbitrary a => Gen a
arbitrary Gen (Integer -> ScriptPurpose) -> Gen Integer -> Gen ScriptPurpose
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 Integer
forall a. Arbitrary a => Gen a
arbitrary
      ]
  {-# INLINEABLE shrink #-}
  shrink :: ScriptPurpose -> [ScriptPurpose]
shrink = \case
    PLA.Minting ScriptHash
sh CurrencySymbol
cs -> ScriptHash -> CurrencySymbol -> ScriptPurpose
PLA.Minting ScriptHash
sh (CurrencySymbol -> ScriptPurpose)
-> [CurrencySymbol] -> [ScriptPurpose]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> CurrencySymbol -> [CurrencySymbol]
forall a. Arbitrary a => a -> [a]
shrink CurrencySymbol
cs
    PLA.Spending ScriptHash
sh TxOutRef
tor -> ScriptHash -> TxOutRef -> ScriptPurpose
PLA.Spending ScriptHash
sh (TxOutRef -> ScriptPurpose) -> [TxOutRef] -> [ScriptPurpose]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> TxOutRef -> [TxOutRef]
forall a. Arbitrary a => a -> [a]
shrink TxOutRef
tor
    PLA.Withdrawing ScriptHash
_ Credential
_ -> []
    PLA.Certifying ScriptHash
sh Integer
i TxCert
cert -> ScriptHash -> Integer -> TxCert -> ScriptPurpose
PLA.Certifying ScriptHash
sh (Integer -> TxCert -> ScriptPurpose)
-> [Integer] -> [TxCert -> ScriptPurpose]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Integer -> [Integer]
forall a. Arbitrary a => a -> [a]
shrink Integer
i [TxCert -> ScriptPurpose] -> [TxCert] -> [ScriptPurpose]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> TxCert -> [TxCert]
forall a. Arbitrary a => a -> [a]
shrink TxCert
cert
    PLA.Voting ScriptHash
sh Voter
v -> ScriptHash -> Voter -> ScriptPurpose
PLA.Voting ScriptHash
sh (Voter -> ScriptPurpose) -> [Voter] -> [ScriptPurpose]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Voter -> [Voter]
forall a. Arbitrary a => a -> [a]
shrink Voter
v
    PLA.Proposing ScriptHash
sh Integer
i ProposalProcedure
pp -> ScriptHash -> Integer -> ProposalProcedure -> ScriptPurpose
PLA.Proposing ScriptHash
sh (Integer -> ProposalProcedure -> ScriptPurpose)
-> [Integer] -> [ProposalProcedure -> ScriptPurpose]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Integer -> [Integer]
forall a. Arbitrary a => a -> [a]
shrink Integer
i [ProposalProcedure -> ScriptPurpose]
-> [ProposalProcedure] -> [ScriptPurpose]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> ProposalProcedure -> [ProposalProcedure]
forall a. Arbitrary a => a -> [a]
shrink ProposalProcedure
pp
    PLA.Guarding ScriptHash
sh Integer
i -> ScriptHash -> Integer -> ScriptPurpose
PLA.Guarding ScriptHash
sh (Integer -> ScriptPurpose) -> [Integer] -> [ScriptPurpose]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Integer -> [Integer]
forall a. Arbitrary a => a -> [a]
shrink Integer
i

-- TODO: CoArbitrary, Function

{- | Does not shrink.

@since 1.4.0
-}
instance Arbitrary PLA.POSIXTimeRange where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen POSIXTimeRange
arbitrary =
    [Gen POSIXTimeRange] -> Gen POSIXTimeRange
forall a. HasCallStack => [Gen a] -> Gen a
oneof
      [ -- always
        POSIXTimeRange -> Gen POSIXTimeRange
forall a. a -> Gen a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (POSIXTimeRange -> Gen POSIXTimeRange)
-> (Maybe POSIXTime -> POSIXTimeRange)
-> Maybe POSIXTime
-> Gen POSIXTimeRange
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe POSIXTime -> Maybe POSIXTime -> POSIXTimeRange
PLA.POSIXTimeRange Maybe POSIXTime
forall a. Maybe a
Nothing (Maybe POSIXTime -> Gen POSIXTimeRange)
-> Maybe POSIXTime -> Gen POSIXTimeRange
forall a b. (a -> b) -> a -> b
$ Maybe POSIXTime
forall a. Maybe a
Nothing
      , -- lower bound only
        Maybe POSIXTime -> Maybe POSIXTime -> POSIXTimeRange
PLA.POSIXTimeRange (Maybe POSIXTime -> Maybe POSIXTime -> POSIXTimeRange)
-> (POSIXTime -> Maybe POSIXTime)
-> POSIXTime
-> Maybe POSIXTime
-> POSIXTimeRange
forall b c a. (b -> c) -> (a -> b) -> a -> c
. POSIXTime -> Maybe POSIXTime
forall a. a -> Maybe a
Just (POSIXTime -> Maybe POSIXTime -> POSIXTimeRange)
-> Gen POSIXTime -> Gen (Maybe POSIXTime -> POSIXTimeRange)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen POSIXTime
forall a. Arbitrary a => Gen a
arbitrary Gen (Maybe POSIXTime -> POSIXTimeRange)
-> Gen (Maybe POSIXTime) -> Gen POSIXTimeRange
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
<*> Maybe POSIXTime -> Gen (Maybe POSIXTime)
forall a. a -> Gen a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure Maybe POSIXTime
forall a. Maybe a
Nothing
      , -- upper bound only
        Maybe POSIXTime -> Maybe POSIXTime -> POSIXTimeRange
PLA.POSIXTimeRange Maybe POSIXTime
forall a. Maybe a
Nothing (Maybe POSIXTime -> POSIXTimeRange)
-> (POSIXTime -> Maybe POSIXTime) -> POSIXTime -> POSIXTimeRange
forall b c a. (b -> c) -> (a -> b) -> a -> c
. POSIXTime -> Maybe POSIXTime
forall a. a -> Maybe a
Just (POSIXTime -> POSIXTimeRange)
-> Gen POSIXTime -> Gen POSIXTimeRange
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen POSIXTime
forall a. Arbitrary a => Gen a
arbitrary
      , -- lower and upper
        do
          POSIXTime
range <- Gen POSIXTime
forall a. Arbitrary a => Gen a
arbitrary
          POSIXTime
start <- Positive POSIXTime -> POSIXTime
forall a. Positive a -> a
getPositive (Positive POSIXTime -> POSIXTime)
-> Gen (Positive POSIXTime) -> Gen POSIXTime
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Positive POSIXTime)
forall a. Arbitrary a => Gen a
arbitrary
          POSIXTimeRange -> Gen POSIXTimeRange
forall a. a -> Gen a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (POSIXTimeRange -> Gen POSIXTimeRange)
-> (POSIXTime -> POSIXTimeRange) -> POSIXTime -> Gen POSIXTimeRange
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe POSIXTime -> Maybe POSIXTime -> POSIXTimeRange
PLA.POSIXTimeRange (POSIXTime -> Maybe POSIXTime
forall a. a -> Maybe a
Just POSIXTime
start) (Maybe POSIXTime -> POSIXTimeRange)
-> (POSIXTime -> Maybe POSIXTime) -> POSIXTime -> POSIXTimeRange
forall b c a. (b -> c) -> (a -> b) -> a -> c
. POSIXTime -> Maybe POSIXTime
forall a. a -> Maybe a
Just (POSIXTime -> Gen POSIXTimeRange)
-> POSIXTime -> Gen POSIXTimeRange
forall a b. (a -> b) -> a -> b
$ POSIXTime
start POSIXTime -> POSIXTime -> POSIXTime
forall a. Num a => a -> a -> a
+ POSIXTime
range
      ]

-- | @since 1.4.0
instance Arbitrary PLA.TxInfo where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen TxInfo
arbitrary = do
    TxId
iid <- Gen TxId
forall a. Arbitrary a => Gen a
arbitrary
    Maybe Integer
subTxIx <- Gen (Maybe Integer)
forall a. Arbitrary a => Gen a
arbitrary
    [TxInInfo]
ins <- NonEmptyList TxInInfo -> [TxInInfo]
forall a. NonEmptyList a -> [a]
getNonEmpty (NonEmptyList TxInInfo -> [TxInInfo])
-> Gen (NonEmptyList TxInInfo) -> Gen [TxInInfo]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (NonEmptyList TxInInfo)
forall a. Arbitrary a => Gen a
arbitrary
    [TxInInfo]
refIns <- Gen [TxInInfo]
forall a. Arbitrary a => Gen a
arbitrary
    [TxOut]
outs <- NonEmptyList TxOut -> [TxOut]
forall a. NonEmptyList a -> [a]
getNonEmpty (NonEmptyList TxOut -> [TxOut])
-> Gen (NonEmptyList TxOut) -> Gen [TxOut]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (NonEmptyList TxOut)
forall a. Arbitrary a => Gen a
arbitrary
    MintValue
mint <- Gen MintValue
forall a. Arbitrary a => Gen a
arbitrary
    [TxCert]
certs <- Gen [TxCert]
forall a. Arbitrary a => Gen a
arbitrary
    Map Credential Lovelace
wdrls <- Gen (Map Credential Lovelace)
forall a. Arbitrary a => Gen a
arbitrary
    Map Credential Lovelace
directs <- Gen (Map Credential Lovelace)
forall a. Arbitrary a => Gen a
arbitrary
    AccountBalanceIntervals
abints <- Gen AccountBalanceIntervals
forall a. Arbitrary a => Gen a
arbitrary
    POSIXTimeRange
valid <- Gen POSIXTimeRange
forall a. Arbitrary a => Gen a
arbitrary
    [Credential]
guards <- Gen [Credential]
forall a. Arbitrary a => Gen a
arbitrary
    Map Credential (Maybe Datum)
reqGuards <- Gen (Map Credential (Maybe Datum))
forall a. Arbitrary a => Gen a
arbitrary
    Map ScriptPurpose Redeemer
reds <- Gen (Map ScriptPurpose Redeemer)
forall a. Arbitrary a => Gen a
arbitrary
    Map DatumHash Datum
dats <- Gen (Map DatumHash Datum)
forall a. Arbitrary a => Gen a
arbitrary
    Map Voter (Map GovernanceActionId Vote)
votes <- Gen (Map Voter (Map GovernanceActionId Vote))
forall a. Arbitrary a => Gen a
arbitrary
    [ProposalProcedure]
pps <- Gen [ProposalProcedure]
forall a. Arbitrary a => Gen a
arbitrary
    Maybe Lovelace
currT <- Gen (Maybe Lovelace)
forall a. Arbitrary a => Gen a
arbitrary
    Lovelace
tDonation <- Gen Lovelace
forall a. Arbitrary a => Gen a
arbitrary
    TxInfo -> Gen TxInfo
forall a. a -> Gen a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure
      (TxInfo -> Gen TxInfo)
-> (Lovelace -> TxInfo) -> Lovelace -> Gen TxInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxId
-> Maybe Integer
-> [TxInInfo]
-> [TxInInfo]
-> [TxOut]
-> MintValue
-> [TxCert]
-> Map Credential Lovelace
-> Map Credential Lovelace
-> AccountBalanceIntervals
-> POSIXTimeRange
-> [Credential]
-> Map Credential (Maybe Datum)
-> Map ScriptPurpose Redeemer
-> Map DatumHash Datum
-> Map Voter (Map GovernanceActionId Vote)
-> [ProposalProcedure]
-> Maybe Lovelace
-> Lovelace
-> TxInfo
PLA.TxInfo
        TxId
iid
        Maybe Integer
subTxIx
        [TxInInfo]
ins
        [TxInInfo]
refIns
        [TxOut]
outs
        MintValue
mint
        [TxCert]
certs
        Map Credential Lovelace
wdrls
        Map Credential Lovelace
directs
        AccountBalanceIntervals
abints
        POSIXTimeRange
valid
        [Credential]
guards
        Map Credential (Maybe Datum)
reqGuards
        Map ScriptPurpose Redeemer
reds
        Map DatumHash Datum
dats
        Map Voter (Map GovernanceActionId Vote)
votes
        [ProposalProcedure]
pps
        Maybe Lovelace
currT
      (Lovelace -> Gen TxInfo) -> Lovelace -> Gen TxInfo
forall a b. (a -> b) -> a -> b
$ Lovelace
tDonation
  {-# INLINEABLE shrink #-}
  shrink :: TxInfo -> [TxInfo]
shrink (PLA.TxInfo TxId
iid Maybe Integer
subTxIx [TxInInfo]
ins [TxInInfo]
refIns [TxOut]
outs MintValue
mint [TxCert]
certs Map Credential Lovelace
wdrls Map Credential Lovelace
directs AccountBalanceIntervals
abints POSIXTimeRange
valid [Credential]
guards Map Credential (Maybe Datum)
reqGuards Map ScriptPurpose Redeemer
reds Map DatumHash Datum
dats Map Voter (Map GovernanceActionId Vote)
votes [ProposalProcedure]
pps Maybe Lovelace
currT Lovelace
tDonation) = do
    [TxInInfo]
ins' <- NonEmptyList TxInInfo -> [TxInInfo]
forall a. NonEmptyList a -> [a]
getNonEmpty (NonEmptyList TxInInfo -> [TxInInfo])
-> [NonEmptyList TxInInfo] -> [[TxInInfo]]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> NonEmptyList TxInInfo -> [NonEmptyList TxInInfo]
forall a. Arbitrary a => a -> [a]
shrink ([TxInInfo] -> NonEmptyList TxInInfo
forall a. [a] -> NonEmptyList a
NonEmpty [TxInInfo]
ins)
    [TxOut]
outs' <- NonEmptyList TxOut -> [TxOut]
forall a. NonEmptyList a -> [a]
getNonEmpty (NonEmptyList TxOut -> [TxOut])
-> [NonEmptyList TxOut] -> [[TxOut]]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> NonEmptyList TxOut -> [NonEmptyList TxOut]
forall a. Arbitrary a => a -> [a]
shrink ([TxOut] -> NonEmptyList TxOut
forall a. [a] -> NonEmptyList a
NonEmpty [TxOut]
outs)
    TxId
-> Maybe Integer
-> [TxInInfo]
-> [TxInInfo]
-> [TxOut]
-> MintValue
-> [TxCert]
-> Map Credential Lovelace
-> Map Credential Lovelace
-> AccountBalanceIntervals
-> POSIXTimeRange
-> [Credential]
-> Map Credential (Maybe Datum)
-> Map ScriptPurpose Redeemer
-> Map DatumHash Datum
-> Map Voter (Map GovernanceActionId Vote)
-> [ProposalProcedure]
-> Maybe Lovelace
-> Lovelace
-> TxInfo
PLA.TxInfo TxId
iid
      (Maybe Integer
 -> [TxInInfo]
 -> [TxInInfo]
 -> [TxOut]
 -> MintValue
 -> [TxCert]
 -> Map Credential Lovelace
 -> Map Credential Lovelace
 -> AccountBalanceIntervals
 -> POSIXTimeRange
 -> [Credential]
 -> Map Credential (Maybe Datum)
 -> Map ScriptPurpose Redeemer
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TxInfo)
-> [Maybe Integer]
-> [[TxInInfo]
    -> [TxInInfo]
    -> [TxOut]
    -> MintValue
    -> [TxCert]
    -> Map Credential Lovelace
    -> Map Credential Lovelace
    -> AccountBalanceIntervals
    -> POSIXTimeRange
    -> [Credential]
    -> Map Credential (Maybe Datum)
    -> Map ScriptPurpose Redeemer
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TxInfo]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Integer -> [Maybe Integer]
forall a. Arbitrary a => a -> [a]
shrink Maybe Integer
subTxIx
      [[TxInInfo]
 -> [TxInInfo]
 -> [TxOut]
 -> MintValue
 -> [TxCert]
 -> Map Credential Lovelace
 -> Map Credential Lovelace
 -> AccountBalanceIntervals
 -> POSIXTimeRange
 -> [Credential]
 -> Map Credential (Maybe Datum)
 -> Map ScriptPurpose Redeemer
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TxInfo]
-> [[TxInInfo]]
-> [[TxInInfo]
    -> [TxOut]
    -> MintValue
    -> [TxCert]
    -> Map Credential Lovelace
    -> Map Credential Lovelace
    -> AccountBalanceIntervals
    -> POSIXTimeRange
    -> [Credential]
    -> Map Credential (Maybe Datum)
    -> Map ScriptPurpose Redeemer
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TxInfo]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> [TxInInfo] -> [[TxInInfo]]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure [TxInInfo]
ins'
      [[TxInInfo]
 -> [TxOut]
 -> MintValue
 -> [TxCert]
 -> Map Credential Lovelace
 -> Map Credential Lovelace
 -> AccountBalanceIntervals
 -> POSIXTimeRange
 -> [Credential]
 -> Map Credential (Maybe Datum)
 -> Map ScriptPurpose Redeemer
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TxInfo]
-> [[TxInInfo]]
-> [[TxOut]
    -> MintValue
    -> [TxCert]
    -> Map Credential Lovelace
    -> Map Credential Lovelace
    -> AccountBalanceIntervals
    -> POSIXTimeRange
    -> [Credential]
    -> Map Credential (Maybe Datum)
    -> Map ScriptPurpose Redeemer
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TxInfo]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> [TxInInfo] -> [[TxInInfo]]
forall a. Arbitrary a => a -> [a]
shrink [TxInInfo]
refIns
      [[TxOut]
 -> MintValue
 -> [TxCert]
 -> Map Credential Lovelace
 -> Map Credential Lovelace
 -> AccountBalanceIntervals
 -> POSIXTimeRange
 -> [Credential]
 -> Map Credential (Maybe Datum)
 -> Map ScriptPurpose Redeemer
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TxInfo]
-> [[TxOut]]
-> [MintValue
    -> [TxCert]
    -> Map Credential Lovelace
    -> Map Credential Lovelace
    -> AccountBalanceIntervals
    -> POSIXTimeRange
    -> [Credential]
    -> Map Credential (Maybe Datum)
    -> Map ScriptPurpose Redeemer
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TxInfo]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> [TxOut] -> [[TxOut]]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure [TxOut]
outs'
      [MintValue
 -> [TxCert]
 -> Map Credential Lovelace
 -> Map Credential Lovelace
 -> AccountBalanceIntervals
 -> POSIXTimeRange
 -> [Credential]
 -> Map Credential (Maybe Datum)
 -> Map ScriptPurpose Redeemer
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TxInfo]
-> [MintValue]
-> [[TxCert]
    -> Map Credential Lovelace
    -> Map Credential Lovelace
    -> AccountBalanceIntervals
    -> POSIXTimeRange
    -> [Credential]
    -> Map Credential (Maybe Datum)
    -> Map ScriptPurpose Redeemer
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TxInfo]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> MintValue -> [MintValue]
forall a. Arbitrary a => a -> [a]
shrink MintValue
mint
      [[TxCert]
 -> Map Credential Lovelace
 -> Map Credential Lovelace
 -> AccountBalanceIntervals
 -> POSIXTimeRange
 -> [Credential]
 -> Map Credential (Maybe Datum)
 -> Map ScriptPurpose Redeemer
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TxInfo]
-> [[TxCert]]
-> [Map Credential Lovelace
    -> Map Credential Lovelace
    -> AccountBalanceIntervals
    -> POSIXTimeRange
    -> [Credential]
    -> Map Credential (Maybe Datum)
    -> Map ScriptPurpose Redeemer
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TxInfo]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> [TxCert] -> [[TxCert]]
forall a. Arbitrary a => a -> [a]
shrink [TxCert]
certs
      [Map Credential Lovelace
 -> Map Credential Lovelace
 -> AccountBalanceIntervals
 -> POSIXTimeRange
 -> [Credential]
 -> Map Credential (Maybe Datum)
 -> Map ScriptPurpose Redeemer
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TxInfo]
-> [Map Credential Lovelace]
-> [Map Credential Lovelace
    -> AccountBalanceIntervals
    -> POSIXTimeRange
    -> [Credential]
    -> Map Credential (Maybe Datum)
    -> Map ScriptPurpose Redeemer
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TxInfo]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Map Credential Lovelace -> [Map Credential Lovelace]
forall a. Arbitrary a => a -> [a]
shrink Map Credential Lovelace
wdrls
      [Map Credential Lovelace
 -> AccountBalanceIntervals
 -> POSIXTimeRange
 -> [Credential]
 -> Map Credential (Maybe Datum)
 -> Map ScriptPurpose Redeemer
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TxInfo]
-> [Map Credential Lovelace]
-> [AccountBalanceIntervals
    -> POSIXTimeRange
    -> [Credential]
    -> Map Credential (Maybe Datum)
    -> Map ScriptPurpose Redeemer
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TxInfo]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Map Credential Lovelace -> [Map Credential Lovelace]
forall a. Arbitrary a => a -> [a]
shrink Map Credential Lovelace
directs
      [AccountBalanceIntervals
 -> POSIXTimeRange
 -> [Credential]
 -> Map Credential (Maybe Datum)
 -> Map ScriptPurpose Redeemer
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TxInfo]
-> [AccountBalanceIntervals]
-> [POSIXTimeRange
    -> [Credential]
    -> Map Credential (Maybe Datum)
    -> Map ScriptPurpose Redeemer
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TxInfo]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> AccountBalanceIntervals -> [AccountBalanceIntervals]
forall a. Arbitrary a => a -> [a]
shrink AccountBalanceIntervals
abints
      [POSIXTimeRange
 -> [Credential]
 -> Map Credential (Maybe Datum)
 -> Map ScriptPurpose Redeemer
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TxInfo]
-> [POSIXTimeRange]
-> [[Credential]
    -> Map Credential (Maybe Datum)
    -> Map ScriptPurpose Redeemer
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TxInfo]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> POSIXTimeRange -> [POSIXTimeRange]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure POSIXTimeRange
valid
      [[Credential]
 -> Map Credential (Maybe Datum)
 -> Map ScriptPurpose Redeemer
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TxInfo]
-> [[Credential]]
-> [Map Credential (Maybe Datum)
    -> Map ScriptPurpose Redeemer
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TxInfo]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> [Credential] -> [[Credential]]
forall a. Arbitrary a => a -> [a]
shrink [Credential]
guards
      [Map Credential (Maybe Datum)
 -> Map ScriptPurpose Redeemer
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TxInfo]
-> [Map Credential (Maybe Datum)]
-> [Map ScriptPurpose Redeemer
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TxInfo]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Map Credential (Maybe Datum) -> [Map Credential (Maybe Datum)]
forall a. Arbitrary a => a -> [a]
shrink Map Credential (Maybe Datum)
reqGuards
      [Map ScriptPurpose Redeemer
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TxInfo]
-> [Map ScriptPurpose Redeemer]
-> [Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TxInfo]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Map ScriptPurpose Redeemer -> [Map ScriptPurpose Redeemer]
forall a. Arbitrary a => a -> [a]
shrink Map ScriptPurpose Redeemer
reds
      [Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TxInfo]
-> [Map DatumHash Datum]
-> [Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure] -> Maybe Lovelace -> Lovelace -> TxInfo]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Map DatumHash Datum -> [Map DatumHash Datum]
forall a. Arbitrary a => a -> [a]
shrink Map DatumHash Datum
dats
      [Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure] -> Maybe Lovelace -> Lovelace -> TxInfo]
-> [Map Voter (Map GovernanceActionId Vote)]
-> [[ProposalProcedure] -> Maybe Lovelace -> Lovelace -> TxInfo]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Map Voter (Map GovernanceActionId Vote)
-> [Map Voter (Map GovernanceActionId Vote)]
forall a. Arbitrary a => a -> [a]
shrink Map Voter (Map GovernanceActionId Vote)
votes
      [[ProposalProcedure] -> Maybe Lovelace -> Lovelace -> TxInfo]
-> [[ProposalProcedure]] -> [Maybe Lovelace -> Lovelace -> TxInfo]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> [ProposalProcedure] -> [[ProposalProcedure]]
forall a. Arbitrary a => a -> [a]
shrink [ProposalProcedure]
pps
      [Maybe Lovelace -> Lovelace -> TxInfo]
-> [Maybe Lovelace] -> [Lovelace -> TxInfo]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Maybe Lovelace -> [Maybe Lovelace]
forall a. Arbitrary a => a -> [a]
shrink Maybe Lovelace
currT
      [Lovelace -> TxInfo] -> [Lovelace] -> [TxInfo]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Lovelace -> [Lovelace]
forall a. Arbitrary a => a -> [a]
shrink Lovelace
tDonation

-- TODO: CoArbitrary, Function

-- | @since 1.4.0
instance Arbitrary PLA.TopTxInfoSimplified where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen TopTxInfoSimplified
arbitrary = do
    [TxId]
ids <- Gen [TxId]
forall a. Arbitrary a => Gen a
arbitrary
    [TxInInfo]
ins <- NonEmptyList TxInInfo -> [TxInInfo]
forall a. NonEmptyList a -> [a]
getNonEmpty (NonEmptyList TxInInfo -> [TxInInfo])
-> Gen (NonEmptyList TxInInfo) -> Gen [TxInInfo]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (NonEmptyList TxInInfo)
forall a. Arbitrary a => Gen a
arbitrary
    [TxInInfo]
refIns <- Gen [TxInInfo]
forall a. Arbitrary a => Gen a
arbitrary
    [TxOut]
outs <- NonEmptyList TxOut -> [TxOut]
forall a. NonEmptyList a -> [a]
getNonEmpty (NonEmptyList TxOut -> [TxOut])
-> Gen (NonEmptyList TxOut) -> Gen [TxOut]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (NonEmptyList TxOut)
forall a. Arbitrary a => Gen a
arbitrary
    MintValue
mints <- Gen MintValue
forall a. Arbitrary a => Gen a
arbitrary
    MintValue
burns <- Gen MintValue
forall a. Arbitrary a => Gen a
arbitrary
    [TxCert]
certs <- Gen [TxCert]
forall a. Arbitrary a => Gen a
arbitrary
    Map Credential Lovelace
wdrls <- Gen (Map Credential Lovelace)
forall a. Arbitrary a => Gen a
arbitrary
    Map Credential Lovelace
dds <- Gen (Map Credential Lovelace)
forall a. Arbitrary a => Gen a
arbitrary
    POSIXTimeRange
valid <- Gen POSIXTimeRange
forall a. Arbitrary a => Gen a
arbitrary
    [Credential]
guards <- Gen [Credential]
forall a. Arbitrary a => Gen a
arbitrary
    [Credential]
reqGuards <- Gen [Credential]
forall a. Arbitrary a => Gen a
arbitrary
    [ScriptHash]
redHashes <- Gen [ScriptHash]
forall a. Arbitrary a => Gen a
arbitrary
    Map DatumHash Datum
datas <- Gen (Map DatumHash Datum)
forall a. Arbitrary a => Gen a
arbitrary
    Map Voter (Map GovernanceActionId Vote)
votes <- Gen (Map Voter (Map GovernanceActionId Vote))
forall a. Arbitrary a => Gen a
arbitrary
    [ProposalProcedure]
pps <- Gen [ProposalProcedure]
forall a. Arbitrary a => Gen a
arbitrary
    Maybe Lovelace
currT <- Gen (Maybe Lovelace)
forall a. Arbitrary a => Gen a
arbitrary
    Lovelace
tDonations <- Gen Lovelace
forall a. Arbitrary a => Gen a
arbitrary
    TopTxInfoSimplified -> Gen TopTxInfoSimplified
forall a. a -> Gen a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure
      (TopTxInfoSimplified -> Gen TopTxInfoSimplified)
-> (Lovelace -> TopTxInfoSimplified)
-> Lovelace
-> Gen TopTxInfoSimplified
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [TxId]
-> [TxInInfo]
-> [TxInInfo]
-> [TxOut]
-> MintValue
-> MintValue
-> [TxCert]
-> Map Credential Lovelace
-> Map Credential Lovelace
-> POSIXTimeRange
-> [Credential]
-> [Credential]
-> [ScriptHash]
-> Map DatumHash Datum
-> Map Voter (Map GovernanceActionId Vote)
-> [ProposalProcedure]
-> Maybe Lovelace
-> Lovelace
-> TopTxInfoSimplified
PLA.TopTxInfoSimplified
        [TxId]
ids
        [TxInInfo]
ins
        [TxInInfo]
refIns
        [TxOut]
outs
        MintValue
mints
        MintValue
burns
        [TxCert]
certs
        Map Credential Lovelace
wdrls
        Map Credential Lovelace
dds
        POSIXTimeRange
valid
        [Credential]
guards
        [Credential]
reqGuards
        [ScriptHash]
redHashes
        Map DatumHash Datum
datas
        Map Voter (Map GovernanceActionId Vote)
votes
        [ProposalProcedure]
pps
        Maybe Lovelace
currT
      (Lovelace -> Gen TopTxInfoSimplified)
-> Lovelace -> Gen TopTxInfoSimplified
forall a b. (a -> b) -> a -> b
$ Lovelace
tDonations
  {-# INLINEABLE shrink #-}
  shrink :: TopTxInfoSimplified -> [TopTxInfoSimplified]
shrink (PLA.TopTxInfoSimplified [TxId]
ids [TxInInfo]
ins [TxInInfo]
refIns [TxOut]
outs MintValue
mints MintValue
burns [TxCert]
certs Map Credential Lovelace
wdrls Map Credential Lovelace
dds POSIXTimeRange
valid [Credential]
guards [Credential]
reqGuards [ScriptHash]
reds Map DatumHash Datum
datas Map Voter (Map GovernanceActionId Vote)
votes [ProposalProcedure]
pps Maybe Lovelace
currT Lovelace
tDonations) = do
    [TxInInfo]
ins' <- NonEmptyList TxInInfo -> [TxInInfo]
forall a. NonEmptyList a -> [a]
getNonEmpty (NonEmptyList TxInInfo -> [TxInInfo])
-> [NonEmptyList TxInInfo] -> [[TxInInfo]]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> NonEmptyList TxInInfo -> [NonEmptyList TxInInfo]
forall a. Arbitrary a => a -> [a]
shrink ([TxInInfo] -> NonEmptyList TxInInfo
forall a. [a] -> NonEmptyList a
NonEmpty [TxInInfo]
ins)
    [TxOut]
outs' <- NonEmptyList TxOut -> [TxOut]
forall a. NonEmptyList a -> [a]
getNonEmpty (NonEmptyList TxOut -> [TxOut])
-> [NonEmptyList TxOut] -> [[TxOut]]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> NonEmptyList TxOut -> [NonEmptyList TxOut]
forall a. Arbitrary a => a -> [a]
shrink ([TxOut] -> NonEmptyList TxOut
forall a. [a] -> NonEmptyList a
NonEmpty [TxOut]
outs)
    [TxId]
-> [TxInInfo]
-> [TxInInfo]
-> [TxOut]
-> MintValue
-> MintValue
-> [TxCert]
-> Map Credential Lovelace
-> Map Credential Lovelace
-> POSIXTimeRange
-> [Credential]
-> [Credential]
-> [ScriptHash]
-> Map DatumHash Datum
-> Map Voter (Map GovernanceActionId Vote)
-> [ProposalProcedure]
-> Maybe Lovelace
-> Lovelace
-> TopTxInfoSimplified
PLA.TopTxInfoSimplified
      ([TxId]
 -> [TxInInfo]
 -> [TxInInfo]
 -> [TxOut]
 -> MintValue
 -> MintValue
 -> [TxCert]
 -> Map Credential Lovelace
 -> Map Credential Lovelace
 -> POSIXTimeRange
 -> [Credential]
 -> [Credential]
 -> [ScriptHash]
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TopTxInfoSimplified)
-> [[TxId]]
-> [[TxInInfo]
    -> [TxInInfo]
    -> [TxOut]
    -> MintValue
    -> MintValue
    -> [TxCert]
    -> Map Credential Lovelace
    -> Map Credential Lovelace
    -> POSIXTimeRange
    -> [Credential]
    -> [Credential]
    -> [ScriptHash]
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TopTxInfoSimplified]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> [TxId] -> [[TxId]]
forall a. Arbitrary a => a -> [a]
shrink [TxId]
ids
      [[TxInInfo]
 -> [TxInInfo]
 -> [TxOut]
 -> MintValue
 -> MintValue
 -> [TxCert]
 -> Map Credential Lovelace
 -> Map Credential Lovelace
 -> POSIXTimeRange
 -> [Credential]
 -> [Credential]
 -> [ScriptHash]
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TopTxInfoSimplified]
-> [[TxInInfo]]
-> [[TxInInfo]
    -> [TxOut]
    -> MintValue
    -> MintValue
    -> [TxCert]
    -> Map Credential Lovelace
    -> Map Credential Lovelace
    -> POSIXTimeRange
    -> [Credential]
    -> [Credential]
    -> [ScriptHash]
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TopTxInfoSimplified]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> [TxInInfo] -> [[TxInInfo]]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure [TxInInfo]
ins'
      [[TxInInfo]
 -> [TxOut]
 -> MintValue
 -> MintValue
 -> [TxCert]
 -> Map Credential Lovelace
 -> Map Credential Lovelace
 -> POSIXTimeRange
 -> [Credential]
 -> [Credential]
 -> [ScriptHash]
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TopTxInfoSimplified]
-> [[TxInInfo]]
-> [[TxOut]
    -> MintValue
    -> MintValue
    -> [TxCert]
    -> Map Credential Lovelace
    -> Map Credential Lovelace
    -> POSIXTimeRange
    -> [Credential]
    -> [Credential]
    -> [ScriptHash]
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TopTxInfoSimplified]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> [TxInInfo] -> [[TxInInfo]]
forall a. Arbitrary a => a -> [a]
shrink [TxInInfo]
refIns
      [[TxOut]
 -> MintValue
 -> MintValue
 -> [TxCert]
 -> Map Credential Lovelace
 -> Map Credential Lovelace
 -> POSIXTimeRange
 -> [Credential]
 -> [Credential]
 -> [ScriptHash]
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TopTxInfoSimplified]
-> [[TxOut]]
-> [MintValue
    -> MintValue
    -> [TxCert]
    -> Map Credential Lovelace
    -> Map Credential Lovelace
    -> POSIXTimeRange
    -> [Credential]
    -> [Credential]
    -> [ScriptHash]
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TopTxInfoSimplified]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> [TxOut] -> [[TxOut]]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure [TxOut]
outs'
      [MintValue
 -> MintValue
 -> [TxCert]
 -> Map Credential Lovelace
 -> Map Credential Lovelace
 -> POSIXTimeRange
 -> [Credential]
 -> [Credential]
 -> [ScriptHash]
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TopTxInfoSimplified]
-> [MintValue]
-> [MintValue
    -> [TxCert]
    -> Map Credential Lovelace
    -> Map Credential Lovelace
    -> POSIXTimeRange
    -> [Credential]
    -> [Credential]
    -> [ScriptHash]
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TopTxInfoSimplified]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> MintValue -> [MintValue]
forall a. Arbitrary a => a -> [a]
shrink MintValue
mints
      [MintValue
 -> [TxCert]
 -> Map Credential Lovelace
 -> Map Credential Lovelace
 -> POSIXTimeRange
 -> [Credential]
 -> [Credential]
 -> [ScriptHash]
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TopTxInfoSimplified]
-> [MintValue]
-> [[TxCert]
    -> Map Credential Lovelace
    -> Map Credential Lovelace
    -> POSIXTimeRange
    -> [Credential]
    -> [Credential]
    -> [ScriptHash]
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TopTxInfoSimplified]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> MintValue -> [MintValue]
forall a. Arbitrary a => a -> [a]
shrink MintValue
burns
      [[TxCert]
 -> Map Credential Lovelace
 -> Map Credential Lovelace
 -> POSIXTimeRange
 -> [Credential]
 -> [Credential]
 -> [ScriptHash]
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TopTxInfoSimplified]
-> [[TxCert]]
-> [Map Credential Lovelace
    -> Map Credential Lovelace
    -> POSIXTimeRange
    -> [Credential]
    -> [Credential]
    -> [ScriptHash]
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TopTxInfoSimplified]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> [TxCert] -> [[TxCert]]
forall a. Arbitrary a => a -> [a]
shrink [TxCert]
certs
      [Map Credential Lovelace
 -> Map Credential Lovelace
 -> POSIXTimeRange
 -> [Credential]
 -> [Credential]
 -> [ScriptHash]
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TopTxInfoSimplified]
-> [Map Credential Lovelace]
-> [Map Credential Lovelace
    -> POSIXTimeRange
    -> [Credential]
    -> [Credential]
    -> [ScriptHash]
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TopTxInfoSimplified]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Map Credential Lovelace -> [Map Credential Lovelace]
forall a. Arbitrary a => a -> [a]
shrink Map Credential Lovelace
wdrls
      [Map Credential Lovelace
 -> POSIXTimeRange
 -> [Credential]
 -> [Credential]
 -> [ScriptHash]
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TopTxInfoSimplified]
-> [Map Credential Lovelace]
-> [POSIXTimeRange
    -> [Credential]
    -> [Credential]
    -> [ScriptHash]
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TopTxInfoSimplified]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Map Credential Lovelace -> [Map Credential Lovelace]
forall a. Arbitrary a => a -> [a]
shrink Map Credential Lovelace
dds
      [POSIXTimeRange
 -> [Credential]
 -> [Credential]
 -> [ScriptHash]
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TopTxInfoSimplified]
-> [POSIXTimeRange]
-> [[Credential]
    -> [Credential]
    -> [ScriptHash]
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TopTxInfoSimplified]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> POSIXTimeRange -> [POSIXTimeRange]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure POSIXTimeRange
valid
      [[Credential]
 -> [Credential]
 -> [ScriptHash]
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TopTxInfoSimplified]
-> [[Credential]]
-> [[Credential]
    -> [ScriptHash]
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TopTxInfoSimplified]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> [Credential] -> [[Credential]]
forall a. Arbitrary a => a -> [a]
shrink [Credential]
guards
      [[Credential]
 -> [ScriptHash]
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TopTxInfoSimplified]
-> [[Credential]]
-> [[ScriptHash]
    -> Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TopTxInfoSimplified]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> [Credential] -> [[Credential]]
forall a. Arbitrary a => a -> [a]
shrink [Credential]
reqGuards
      [[ScriptHash]
 -> Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TopTxInfoSimplified]
-> [[ScriptHash]]
-> [Map DatumHash Datum
    -> Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TopTxInfoSimplified]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> [ScriptHash] -> [[ScriptHash]]
forall a. Arbitrary a => a -> [a]
shrink [ScriptHash]
reds
      [Map DatumHash Datum
 -> Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TopTxInfoSimplified]
-> [Map DatumHash Datum]
-> [Map Voter (Map GovernanceActionId Vote)
    -> [ProposalProcedure]
    -> Maybe Lovelace
    -> Lovelace
    -> TopTxInfoSimplified]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Map DatumHash Datum -> [Map DatumHash Datum]
forall a. Arbitrary a => a -> [a]
shrink Map DatumHash Datum
datas
      [Map Voter (Map GovernanceActionId Vote)
 -> [ProposalProcedure]
 -> Maybe Lovelace
 -> Lovelace
 -> TopTxInfoSimplified]
-> [Map Voter (Map GovernanceActionId Vote)]
-> [[ProposalProcedure]
    -> Maybe Lovelace -> Lovelace -> TopTxInfoSimplified]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Map Voter (Map GovernanceActionId Vote)
-> [Map Voter (Map GovernanceActionId Vote)]
forall a. Arbitrary a => a -> [a]
shrink Map Voter (Map GovernanceActionId Vote)
votes
      [[ProposalProcedure]
 -> Maybe Lovelace -> Lovelace -> TopTxInfoSimplified]
-> [[ProposalProcedure]]
-> [Maybe Lovelace -> Lovelace -> TopTxInfoSimplified]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> [ProposalProcedure] -> [[ProposalProcedure]]
forall a. Arbitrary a => a -> [a]
shrink [ProposalProcedure]
pps
      [Maybe Lovelace -> Lovelace -> TopTxInfoSimplified]
-> [Maybe Lovelace] -> [Lovelace -> TopTxInfoSimplified]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Maybe Lovelace -> [Maybe Lovelace]
forall a. Arbitrary a => a -> [a]
shrink Maybe Lovelace
currT
      [Lovelace -> TopTxInfoSimplified]
-> [Lovelace] -> [TopTxInfoSimplified]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Lovelace -> [Lovelace]
forall a. Arbitrary a => a -> [a]
shrink Lovelace
tDonations

-- TODO: CoArbitrary, Function

-- | @since 1.4.0
instance Arbitrary PLA.TopTxInfo where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen TopTxInfo
arbitrary = do
    [TxInfo]
trans <- Gen [TxInfo]
forall a. Arbitrary a => Gen a
arbitrary
    Map TxId Datum
dats <- Gen (Map TxId Datum)
forall a. Arbitrary a => Gen a
arbitrary
    AccountBalanceIntervals
starts <- Gen AccountBalanceIntervals
forall a. Arbitrary a => Gen a
arbitrary
    TopTxInfoSimplified
simple <- Gen TopTxInfoSimplified
forall a. Arbitrary a => Gen a
arbitrary
    TopTxInfo -> Gen TopTxInfo
forall a. a -> Gen a
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (TopTxInfo -> Gen TopTxInfo)
-> (TopTxInfoSimplified -> TopTxInfo)
-> TopTxInfoSimplified
-> Gen TopTxInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [TxInfo]
-> Map TxId Datum
-> AccountBalanceIntervals
-> TopTxInfoSimplified
-> TopTxInfo
PLA.TopTxInfo [TxInfo]
trans Map TxId Datum
dats AccountBalanceIntervals
starts (TopTxInfoSimplified -> Gen TopTxInfo)
-> TopTxInfoSimplified -> Gen TopTxInfo
forall a b. (a -> b) -> a -> b
$ TopTxInfoSimplified
simple
  {-# INLINEABLE shrink #-}
  shrink :: TopTxInfo -> [TopTxInfo]
shrink (PLA.TopTxInfo [TxInfo]
trans Map TxId Datum
dats AccountBalanceIntervals
starts TopTxInfoSimplified
simple) =
    [TxInfo]
-> Map TxId Datum
-> AccountBalanceIntervals
-> TopTxInfoSimplified
-> TopTxInfo
PLA.TopTxInfo ([TxInfo]
 -> Map TxId Datum
 -> AccountBalanceIntervals
 -> TopTxInfoSimplified
 -> TopTxInfo)
-> [[TxInfo]]
-> [Map TxId Datum
    -> AccountBalanceIntervals -> TopTxInfoSimplified -> TopTxInfo]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> [TxInfo] -> [[TxInfo]]
forall a. Arbitrary a => a -> [a]
shrink [TxInfo]
trans [Map TxId Datum
 -> AccountBalanceIntervals -> TopTxInfoSimplified -> TopTxInfo]
-> [Map TxId Datum]
-> [AccountBalanceIntervals -> TopTxInfoSimplified -> TopTxInfo]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Map TxId Datum -> [Map TxId Datum]
forall a. Arbitrary a => a -> [a]
shrink Map TxId Datum
dats [AccountBalanceIntervals -> TopTxInfoSimplified -> TopTxInfo]
-> [AccountBalanceIntervals] -> [TopTxInfoSimplified -> TopTxInfo]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> AccountBalanceIntervals -> [AccountBalanceIntervals]
forall a. Arbitrary a => a -> [a]
shrink AccountBalanceIntervals
starts [TopTxInfoSimplified -> TopTxInfo]
-> [TopTxInfoSimplified] -> [TopTxInfo]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> TopTxInfoSimplified -> [TopTxInfoSimplified]
forall a. Arbitrary a => a -> [a]
shrink TopTxInfoSimplified
simple

-- TODO: CoArbitrary, Function

-- | @since 1.4.0
instance Arbitrary PLA.ScriptInfo where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen ScriptInfo
arbitrary =
    [Gen ScriptInfo] -> Gen ScriptInfo
forall a. HasCallStack => [Gen a] -> Gen a
oneof
      [ CurrencySymbol -> ScriptInfo
PLA.MintingScript (CurrencySymbol -> ScriptInfo)
-> Gen CurrencySymbol -> Gen ScriptInfo
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen CurrencySymbol
forall a. Arbitrary a => Gen a
arbitrary
      , TxOutRef -> Maybe Datum -> ScriptInfo
PLA.SpendingScript (TxOutRef -> Maybe Datum -> ScriptInfo)
-> Gen TxOutRef -> Gen (Maybe Datum -> ScriptInfo)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen TxOutRef
forall a. Arbitrary a => Gen a
arbitrary Gen (Maybe Datum -> ScriptInfo)
-> Gen (Maybe Datum) -> Gen ScriptInfo
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 (Maybe Datum)
forall a. Arbitrary a => Gen a
arbitrary
      , AccountId -> ScriptInfo
PLA.WithdrawingScript (AccountId -> ScriptInfo) -> Gen AccountId -> Gen ScriptInfo
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen AccountId
forall a. Arbitrary a => Gen a
arbitrary
      , Integer -> TxCert -> ScriptInfo
PLA.CertifyingScript (Integer -> TxCert -> ScriptInfo)
-> Gen Integer -> Gen (TxCert -> ScriptInfo)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Integer
forall a. Arbitrary a => Gen a
arbitrary Gen (TxCert -> ScriptInfo) -> Gen TxCert -> Gen ScriptInfo
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 TxCert
forall a. Arbitrary a => Gen a
arbitrary
      , Voter -> ScriptInfo
PLA.VotingScript (Voter -> ScriptInfo) -> Gen Voter -> Gen ScriptInfo
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Voter
forall a. Arbitrary a => Gen a
arbitrary
      , Integer -> ProposalProcedure -> ScriptInfo
PLA.ProposingScript (Integer -> ProposalProcedure -> ScriptInfo)
-> Gen Integer -> Gen (ProposalProcedure -> ScriptInfo)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Integer
forall a. Arbitrary a => Gen a
arbitrary Gen (ProposalProcedure -> ScriptInfo)
-> Gen ProposalProcedure -> Gen ScriptInfo
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 ProposalProcedure
forall a. Arbitrary a => Gen a
arbitrary
      , Integer -> Maybe TopTxInfo -> ScriptInfo
PLA.GuardingScript (Integer -> Maybe TopTxInfo -> ScriptInfo)
-> Gen Integer -> Gen (Maybe TopTxInfo -> ScriptInfo)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen Integer
forall a. Arbitrary a => Gen a
arbitrary Gen (Maybe TopTxInfo -> ScriptInfo)
-> Gen (Maybe TopTxInfo) -> Gen ScriptInfo
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 (Maybe TopTxInfo)
forall a. Arbitrary a => Gen a
arbitrary
      ]
  {-# INLINEABLE shrink #-}
  shrink :: ScriptInfo -> [ScriptInfo]
shrink = \case
    PLA.MintingScript CurrencySymbol
cs -> CurrencySymbol -> ScriptInfo
PLA.MintingScript (CurrencySymbol -> ScriptInfo) -> [CurrencySymbol] -> [ScriptInfo]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> CurrencySymbol -> [CurrencySymbol]
forall a. Arbitrary a => a -> [a]
shrink CurrencySymbol
cs
    PLA.SpendingScript TxOutRef
outRef Maybe Datum
mDat -> do
      TxOutRef
outRef' <- TxOutRef -> [TxOutRef]
forall a. Arbitrary a => a -> [a]
shrink TxOutRef
outRef
      Maybe Datum
mDat' <- Maybe Datum -> [Maybe Datum]
forall a. Arbitrary a => a -> [a]
shrink Maybe Datum
mDat
      (ScriptInfo -> [ScriptInfo]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (ScriptInfo -> [ScriptInfo])
-> (Maybe Datum -> ScriptInfo) -> Maybe Datum -> [ScriptInfo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxOutRef -> Maybe Datum -> ScriptInfo
PLA.SpendingScript TxOutRef
outRef (Maybe Datum -> [ScriptInfo]) -> Maybe Datum -> [ScriptInfo]
forall a b. (a -> b) -> a -> b
$ Maybe Datum
mDat')
        [ScriptInfo] -> [ScriptInfo] -> [ScriptInfo]
forall a. [a] -> [a] -> [a]
forall (f :: Type -> Type) a. Alternative f => f a -> f a -> f a
<|> (ScriptInfo -> [ScriptInfo]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (ScriptInfo -> [ScriptInfo])
-> (Maybe Datum -> ScriptInfo) -> Maybe Datum -> [ScriptInfo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxOutRef -> Maybe Datum -> ScriptInfo
PLA.SpendingScript TxOutRef
outRef' (Maybe Datum -> [ScriptInfo]) -> Maybe Datum -> [ScriptInfo]
forall a b. (a -> b) -> a -> b
$ Maybe Datum
mDat)
    PLA.WithdrawingScript AccountId
aid -> AccountId -> ScriptInfo
PLA.WithdrawingScript (AccountId -> ScriptInfo) -> [AccountId] -> [ScriptInfo]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> AccountId -> [AccountId]
forall a. Arbitrary a => a -> [a]
shrink AccountId
aid
    PLA.CertifyingScript Integer
i TxCert
txCert -> do
      Integer
i' <- Integer -> [Integer]
forall a. Arbitrary a => a -> [a]
shrink Integer
i
      TxCert
txCert' <- TxCert -> [TxCert]
forall a. Arbitrary a => a -> [a]
shrink TxCert
txCert
      (ScriptInfo -> [ScriptInfo]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (ScriptInfo -> [ScriptInfo])
-> (TxCert -> ScriptInfo) -> TxCert -> [ScriptInfo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> TxCert -> ScriptInfo
PLA.CertifyingScript Integer
i (TxCert -> [ScriptInfo]) -> TxCert -> [ScriptInfo]
forall a b. (a -> b) -> a -> b
$ TxCert
txCert')
        [ScriptInfo] -> [ScriptInfo] -> [ScriptInfo]
forall a. [a] -> [a] -> [a]
forall (f :: Type -> Type) a. Alternative f => f a -> f a -> f a
<|> (ScriptInfo -> [ScriptInfo]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (ScriptInfo -> [ScriptInfo])
-> (TxCert -> ScriptInfo) -> TxCert -> [ScriptInfo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> TxCert -> ScriptInfo
PLA.CertifyingScript Integer
i' (TxCert -> [ScriptInfo]) -> TxCert -> [ScriptInfo]
forall a b. (a -> b) -> a -> b
$ TxCert
txCert)
    PLA.VotingScript Voter
v -> Voter -> ScriptInfo
PLA.VotingScript (Voter -> ScriptInfo) -> [Voter] -> [ScriptInfo]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Voter -> [Voter]
forall a. Arbitrary a => a -> [a]
shrink Voter
v
    PLA.ProposingScript Integer
i ProposalProcedure
pp -> do
      Integer
i' <- Integer -> [Integer]
forall a. Arbitrary a => a -> [a]
shrink Integer
i
      ProposalProcedure
pp' <- ProposalProcedure -> [ProposalProcedure]
forall a. Arbitrary a => a -> [a]
shrink ProposalProcedure
pp
      (ScriptInfo -> [ScriptInfo]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (ScriptInfo -> [ScriptInfo])
-> (ProposalProcedure -> ScriptInfo)
-> ProposalProcedure
-> [ScriptInfo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> ProposalProcedure -> ScriptInfo
PLA.ProposingScript Integer
i (ProposalProcedure -> [ScriptInfo])
-> ProposalProcedure -> [ScriptInfo]
forall a b. (a -> b) -> a -> b
$ ProposalProcedure
pp')
        [ScriptInfo] -> [ScriptInfo] -> [ScriptInfo]
forall a. [a] -> [a] -> [a]
forall (f :: Type -> Type) a. Alternative f => f a -> f a -> f a
<|> (ScriptInfo -> [ScriptInfo]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (ScriptInfo -> [ScriptInfo])
-> (ProposalProcedure -> ScriptInfo)
-> ProposalProcedure
-> [ScriptInfo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> ProposalProcedure -> ScriptInfo
PLA.ProposingScript Integer
i' (ProposalProcedure -> [ScriptInfo])
-> ProposalProcedure -> [ScriptInfo]
forall a b. (a -> b) -> a -> b
$ ProposalProcedure
pp)
    PLA.GuardingScript Integer
i Maybe TopTxInfo
mTxInfo -> do
      Integer
i' <- Integer -> [Integer]
forall a. Arbitrary a => a -> [a]
shrink Integer
i
      Maybe TopTxInfo
mTxInfo' <- Maybe TopTxInfo -> [Maybe TopTxInfo]
forall a. Arbitrary a => a -> [a]
shrink Maybe TopTxInfo
mTxInfo
      (ScriptInfo -> [ScriptInfo]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (ScriptInfo -> [ScriptInfo])
-> (Maybe TopTxInfo -> ScriptInfo)
-> Maybe TopTxInfo
-> [ScriptInfo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Maybe TopTxInfo -> ScriptInfo
PLA.GuardingScript Integer
i (Maybe TopTxInfo -> [ScriptInfo])
-> Maybe TopTxInfo -> [ScriptInfo]
forall a b. (a -> b) -> a -> b
$ Maybe TopTxInfo
mTxInfo')
        [ScriptInfo] -> [ScriptInfo] -> [ScriptInfo]
forall a. [a] -> [a] -> [a]
forall (f :: Type -> Type) a. Alternative f => f a -> f a -> f a
<|> (ScriptInfo -> [ScriptInfo]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (ScriptInfo -> [ScriptInfo])
-> (Maybe TopTxInfo -> ScriptInfo)
-> Maybe TopTxInfo
-> [ScriptInfo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Maybe TopTxInfo -> ScriptInfo
PLA.GuardingScript Integer
i' (Maybe TopTxInfo -> [ScriptInfo])
-> Maybe TopTxInfo -> [ScriptInfo]
forall a b. (a -> b) -> a -> b
$ Maybe TopTxInfo
mTxInfo)

-- TODO: CoArbitrary, Function

-- | @since 1.4.0
instance Arbitrary PLA.ScriptContext where
  {-# INLINEABLE arbitrary #-}
  arbitrary :: Gen ScriptContext
arbitrary = TxInfo -> Redeemer -> ScriptInfo -> ScriptHash -> ScriptContext
PLA.ScriptContext (TxInfo -> Redeemer -> ScriptInfo -> ScriptHash -> ScriptContext)
-> Gen TxInfo
-> Gen (Redeemer -> ScriptInfo -> ScriptHash -> ScriptContext)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen TxInfo
forall a. Arbitrary a => Gen a
arbitrary Gen (Redeemer -> ScriptInfo -> ScriptHash -> ScriptContext)
-> Gen Redeemer -> Gen (ScriptInfo -> ScriptHash -> ScriptContext)
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 Redeemer
forall a. Arbitrary a => Gen a
arbitrary Gen (ScriptInfo -> ScriptHash -> ScriptContext)
-> Gen ScriptInfo -> Gen (ScriptHash -> ScriptContext)
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 ScriptInfo
forall a. Arbitrary a => Gen a
arbitrary Gen (ScriptHash -> ScriptContext)
-> Gen ScriptHash -> Gen ScriptContext
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 ScriptHash
forall a. Arbitrary a => Gen a
arbitrary
  {-# INLINEABLE shrink #-}
  shrink :: ScriptContext -> [ScriptContext]
shrink (PLA.ScriptContext TxInfo
info Redeemer
red ScriptInfo
si ScriptHash
sh) =
    TxInfo -> Redeemer -> ScriptInfo -> ScriptHash -> ScriptContext
PLA.ScriptContext (TxInfo -> Redeemer -> ScriptInfo -> ScriptHash -> ScriptContext)
-> [TxInfo]
-> [Redeemer -> ScriptInfo -> ScriptHash -> ScriptContext]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> TxInfo -> [TxInfo]
forall a. Arbitrary a => a -> [a]
shrink TxInfo
info [Redeemer -> ScriptInfo -> ScriptHash -> ScriptContext]
-> [Redeemer] -> [ScriptInfo -> ScriptHash -> ScriptContext]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> Redeemer -> [Redeemer]
forall a. Arbitrary a => a -> [a]
shrink Redeemer
red [ScriptInfo -> ScriptHash -> ScriptContext]
-> [ScriptInfo] -> [ScriptHash -> ScriptContext]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> ScriptInfo -> [ScriptInfo]
forall a. Arbitrary a => a -> [a]
shrink ScriptInfo
si [ScriptHash -> ScriptContext] -> [ScriptHash] -> [ScriptContext]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: Type -> Type) a b.
Applicative f =>
f (a -> b) -> f a -> f b
<*> ScriptHash -> [ScriptHash]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure ScriptHash
sh

-- TODO: CoArbitrary, Function