{-# OPTIONS_GHC -Wno-orphans #-}
module PlutusLedgerApi.V1.Orphans.Contexts () where
import Data.Set qualified as Set
import PlutusLedgerApi.V1 qualified as PLA
import PlutusLedgerApi.V1.Orphans.DCert ()
import PlutusLedgerApi.V1.Orphans.Interval ()
import PlutusLedgerApi.V1.Orphans.Tx ()
import PlutusLedgerApi.V1.Orphans.Value qualified as Value
import Test.QuickCheck (
Arbitrary (arbitrary, shrink),
CoArbitrary (coarbitrary),
Function (function),
NonEmptyList (NonEmpty),
functionMap,
getNonEmpty,
oneof,
variant,
)
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) =
TxOutRef -> TxOut -> TxInInfo
PLA.TxInInfo (TxOutRef -> TxOut -> TxInInfo)
-> [TxOutRef] -> [TxOut -> TxInInfo]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> TxOutRef -> [TxOutRef]
forall a. Arbitrary a => a -> [a]
shrink TxOutRef
outref [TxOut -> TxInInfo] -> [TxOut] -> [TxInInfo]
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. Arbitrary a => a -> [a]
shrink TxOut
resolved
instance CoArbitrary PLA.TxInInfo where
{-# INLINEABLE coarbitrary #-}
coarbitrary :: forall b. TxInInfo -> Gen b -> Gen b
coarbitrary (PLA.TxInInfo TxOutRef
outref TxOut
resolved) =
TxOutRef -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. TxOutRef -> Gen b -> Gen b
coarbitrary TxOutRef
outref (Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxOut -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. TxOut -> Gen b -> Gen b
coarbitrary TxOut
resolved
instance Function PLA.TxInInfo where
{-# INLINEABLE function #-}
function :: forall b. (TxInInfo -> b) -> TxInInfo :-> b
function =
(TxInInfo -> (TxOutRef, TxOut))
-> ((TxOutRef, TxOut) -> TxInInfo)
-> (TxInInfo -> b)
-> TxInInfo :-> b
forall b a c.
Function b =>
(a -> b) -> (b -> a) -> (a -> c) -> a :-> c
functionMap
(\(PLA.TxInInfo TxOutRef
outref TxOut
resolved) -> (TxOutRef
outref, TxOut
resolved))
((TxOutRef -> TxOut -> TxInInfo) -> (TxOutRef, TxOut) -> TxInInfo
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry TxOutRef -> TxOut -> TxInInfo
PLA.TxInInfo)
instance Arbitrary PLA.TxInfo where
{-# INLINEABLE arbitrary #-}
arbitrary :: Gen TxInfo
arbitrary =
[TxInInfo]
-> [TxOut]
-> Value
-> Value
-> [DCert]
-> [(StakingCredential, Integer)]
-> POSIXTimeRange
-> [PubKeyHash]
-> [(DatumHash, Datum)]
-> TxId
-> TxInfo
PLA.TxInfo ([TxInInfo]
-> [TxOut]
-> Value
-> Value
-> [DCert]
-> [(StakingCredential, Integer)]
-> POSIXTimeRange
-> [PubKeyHash]
-> [(DatumHash, Datum)]
-> TxId
-> TxInfo)
-> (NonEmptyList TxInInfo -> [TxInInfo])
-> NonEmptyList TxInInfo
-> [TxOut]
-> Value
-> Value
-> [DCert]
-> [(StakingCredential, Integer)]
-> POSIXTimeRange
-> [PubKeyHash]
-> [(DatumHash, Datum)]
-> TxId
-> TxInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonEmptyList TxInInfo -> [TxInInfo]
forall a. NonEmptyList a -> [a]
getNonEmpty
(NonEmptyList TxInInfo
-> [TxOut]
-> Value
-> Value
-> [DCert]
-> [(StakingCredential, Integer)]
-> POSIXTimeRange
-> [PubKeyHash]
-> [(DatumHash, Datum)]
-> TxId
-> TxInfo)
-> Gen (NonEmptyList TxInInfo)
-> Gen
([TxOut]
-> Value
-> Value
-> [DCert]
-> [(StakingCredential, Integer)]
-> POSIXTimeRange
-> [PubKeyHash]
-> [(DatumHash, Datum)]
-> TxId
-> TxInfo)
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (NonEmptyList TxInInfo)
forall a. Arbitrary a => Gen a
arbitrary
Gen
([TxOut]
-> Value
-> Value
-> [DCert]
-> [(StakingCredential, Integer)]
-> POSIXTimeRange
-> [PubKeyHash]
-> [(DatumHash, Datum)]
-> TxId
-> TxInfo)
-> Gen [TxOut]
-> Gen
(Value
-> Value
-> [DCert]
-> [(StakingCredential, Integer)]
-> POSIXTimeRange
-> [PubKeyHash]
-> [(DatumHash, Datum)]
-> TxId
-> TxInfo)
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
<*> (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)
Gen
(Value
-> Value
-> [DCert]
-> [(StakingCredential, Integer)]
-> POSIXTimeRange
-> [PubKeyHash]
-> [(DatumHash, Datum)]
-> TxId
-> TxInfo)
-> Gen Value
-> Gen
(Value
-> [DCert]
-> [(StakingCredential, Integer)]
-> POSIXTimeRange
-> [PubKeyHash]
-> [(DatumHash, Datum)]
-> TxId
-> TxInfo)
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
<*> (FeeValue -> Value
Value.getFeeValue (FeeValue -> Value) -> Gen FeeValue -> Gen Value
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen FeeValue
forall a. Arbitrary a => Gen a
arbitrary)
Gen
(Value
-> [DCert]
-> [(StakingCredential, Integer)]
-> POSIXTimeRange
-> [PubKeyHash]
-> [(DatumHash, Datum)]
-> TxId
-> TxInfo)
-> Gen Value
-> Gen
([DCert]
-> [(StakingCredential, Integer)]
-> POSIXTimeRange
-> [PubKeyHash]
-> [(DatumHash, Datum)]
-> TxId
-> TxInfo)
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
<*> (MintValue -> Value
Value.getMintValue (MintValue -> Value) -> Gen MintValue -> Gen Value
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen MintValue
forall a. Arbitrary a => Gen a
arbitrary)
Gen
([DCert]
-> [(StakingCredential, Integer)]
-> POSIXTimeRange
-> [PubKeyHash]
-> [(DatumHash, Datum)]
-> TxId
-> TxInfo)
-> Gen [DCert]
-> Gen
([(StakingCredential, Integer)]
-> POSIXTimeRange
-> [PubKeyHash]
-> [(DatumHash, Datum)]
-> TxId
-> TxInfo)
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 [DCert]
forall a. Arbitrary a => Gen a
arbitrary
Gen
([(StakingCredential, Integer)]
-> POSIXTimeRange
-> [PubKeyHash]
-> [(DatumHash, Datum)]
-> TxId
-> TxInfo)
-> Gen [(StakingCredential, Integer)]
-> Gen
(POSIXTimeRange
-> [PubKeyHash] -> [(DatumHash, Datum)] -> TxId -> TxInfo)
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 [(StakingCredential, Integer)]
forall a. Arbitrary a => Gen a
arbitrary
Gen
(POSIXTimeRange
-> [PubKeyHash] -> [(DatumHash, Datum)] -> TxId -> TxInfo)
-> Gen POSIXTimeRange
-> Gen ([PubKeyHash] -> [(DatumHash, Datum)] -> TxId -> TxInfo)
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 POSIXTimeRange
forall a. Arbitrary a => Gen a
arbitrary
Gen ([PubKeyHash] -> [(DatumHash, Datum)] -> TxId -> TxInfo)
-> Gen [PubKeyHash] -> Gen ([(DatumHash, Datum)] -> TxId -> TxInfo)
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
<*> (Set PubKeyHash -> [PubKeyHash]
forall a. Set a -> [a]
Set.toList (Set PubKeyHash -> [PubKeyHash])
-> Gen (Set PubKeyHash) -> Gen [PubKeyHash]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Set PubKeyHash)
forall a. Arbitrary a => Gen a
arbitrary)
Gen ([(DatumHash, Datum)] -> TxId -> TxInfo)
-> Gen [(DatumHash, Datum)] -> Gen (TxId -> TxInfo)
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 [(DatumHash, Datum)]
forall a. Arbitrary a => Gen a
arbitrary
Gen (TxId -> TxInfo) -> Gen TxId -> Gen TxInfo
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 TxId
forall a. Arbitrary a => Gen a
arbitrary
{-# INLINEABLE shrink #-}
shrink :: TxInfo -> [TxInfo]
shrink (PLA.TxInfo [TxInInfo]
ins [TxOut]
outs Value
fee Value
mint [DCert]
dcert [(StakingCredential, Integer)]
wdrl POSIXTimeRange
validRange [PubKeyHash]
sigs [(DatumHash, Datum)]
dats TxId
tid) = do
NonEmpty [TxInInfo]
ins' <- NonEmptyList TxInInfo -> [NonEmptyList TxInInfo]
forall a. Arbitrary a => a -> [a]
shrink ([TxInInfo] -> NonEmptyList TxInInfo
forall a. [a] -> NonEmptyList a
NonEmpty [TxInInfo]
ins)
NonEmpty [TxOut]
outs' <- NonEmptyList TxOut -> [NonEmptyList TxOut]
forall a. Arbitrary a => a -> [a]
shrink ([TxOut] -> NonEmptyList TxOut
forall a. [a] -> NonEmptyList a
NonEmpty [TxOut]
outs)
Value.FeeValue Value
fee' <- FeeValue -> [FeeValue]
forall a. Arbitrary a => a -> [a]
shrink (Value -> FeeValue
Value.FeeValue Value
fee)
Value.MintValue Value
mint' <- MintValue -> [MintValue]
forall a. Arbitrary a => a -> [a]
shrink (Value -> MintValue
Value.MintValue Value
mint)
[DCert]
dcert' <- [DCert] -> [[DCert]]
forall a. Arbitrary a => a -> [a]
shrink [DCert]
dcert
[(StakingCredential, Integer)]
wdrl' <- [(StakingCredential, Integer)] -> [[(StakingCredential, Integer)]]
forall a. Arbitrary a => a -> [a]
shrink [(StakingCredential, Integer)]
wdrl
POSIXTimeRange
validRange' <- POSIXTimeRange -> [POSIXTimeRange]
forall a. Arbitrary a => a -> [a]
shrink POSIXTimeRange
validRange
[PubKeyHash]
sigs' <- Set PubKeyHash -> [PubKeyHash]
forall a. Set a -> [a]
Set.toList (Set PubKeyHash -> [PubKeyHash])
-> [Set PubKeyHash] -> [[PubKeyHash]]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Set PubKeyHash -> [Set PubKeyHash]
forall a. Arbitrary a => a -> [a]
shrink ([PubKeyHash] -> Set PubKeyHash
forall a. Ord a => [a] -> Set a
Set.fromList [PubKeyHash]
sigs)
[(DatumHash, Datum)]
dats' <- [(DatumHash, Datum)] -> [[(DatumHash, Datum)]]
forall a. Arbitrary a => a -> [a]
shrink [(DatumHash, Datum)]
dats
TxId
tid' <- TxId -> [TxId]
forall a. Arbitrary a => a -> [a]
shrink TxId
tid
TxInfo -> [TxInfo]
forall a. a -> [a]
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (TxInfo -> [TxInfo]) -> (TxId -> TxInfo) -> TxId -> [TxInfo]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [TxInInfo]
-> [TxOut]
-> Value
-> Value
-> [DCert]
-> [(StakingCredential, Integer)]
-> POSIXTimeRange
-> [PubKeyHash]
-> [(DatumHash, Datum)]
-> TxId
-> TxInfo
PLA.TxInfo [TxInInfo]
ins' [TxOut]
outs' Value
fee' Value
mint' [DCert]
dcert' [(StakingCredential, Integer)]
wdrl' POSIXTimeRange
validRange' [PubKeyHash]
sigs' [(DatumHash, Datum)]
dats' (TxId -> [TxInfo]) -> TxId -> [TxInfo]
forall a b. (a -> b) -> a -> b
$ TxId
tid'
instance CoArbitrary PLA.TxInfo where
{-# INLINEABLE coarbitrary #-}
coarbitrary :: forall b. TxInfo -> Gen b -> Gen b
coarbitrary (PLA.TxInfo [TxInInfo]
ins [TxOut]
outs Value
fee Value
mint [DCert]
dcert [(StakingCredential, Integer)]
wdrl POSIXTimeRange
validRange [PubKeyHash]
sigs [(DatumHash, Datum)]
dats TxId
tid) =
[TxInInfo] -> Gen b -> Gen b
forall b. [TxInInfo] -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary [TxInInfo]
ins
(Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [TxOut] -> Gen b -> Gen b
forall b. [TxOut] -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary [TxOut]
outs
(Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. Value -> Gen b -> Gen b
coarbitrary Value
fee
(Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. Value -> Gen b -> Gen b
coarbitrary Value
mint
(Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [DCert] -> Gen b -> Gen b
forall b. [DCert] -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary [DCert]
dcert
(Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(StakingCredential, Integer)] -> Gen b -> Gen b
forall b. [(StakingCredential, Integer)] -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary [(StakingCredential, Integer)]
wdrl
(Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. POSIXTimeRange -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. POSIXTimeRange -> Gen b -> Gen b
coarbitrary POSIXTimeRange
validRange
(Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [PubKeyHash] -> Gen b -> Gen b
forall b. [PubKeyHash] -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary [PubKeyHash]
sigs
(Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(DatumHash, Datum)] -> Gen b -> Gen b
forall b. [(DatumHash, Datum)] -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
coarbitrary [(DatumHash, Datum)]
dats
(Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxId -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. TxId -> Gen b -> Gen b
coarbitrary TxId
tid
instance Function PLA.TxInfo where
{-# INLINEABLE function #-}
function :: forall b. (TxInfo -> b) -> TxInfo :-> b
function = (TxInfo
-> ([TxInInfo], [TxOut], Value, Value, [DCert],
([(StakingCredential, Integer)], POSIXTimeRange, [PubKeyHash],
[(DatumHash, Datum)], TxId)))
-> (([TxInInfo], [TxOut], Value, Value, [DCert],
([(StakingCredential, Integer)], POSIXTimeRange, [PubKeyHash],
[(DatumHash, Datum)], TxId))
-> TxInfo)
-> (TxInfo -> b)
-> TxInfo :-> b
forall b a c.
Function b =>
(a -> b) -> (b -> a) -> (a -> c) -> a :-> c
functionMap TxInfo
-> ([TxInInfo], [TxOut], Value, Value, [DCert],
([(StakingCredential, Integer)], POSIXTimeRange, [PubKeyHash],
[(DatumHash, Datum)], TxId))
into ([TxInInfo], [TxOut], Value, Value, [DCert],
([(StakingCredential, Integer)], POSIXTimeRange, [PubKeyHash],
[(DatumHash, Datum)], TxId))
-> TxInfo
outOf
where
into ::
PLA.TxInfo ->
([PLA.TxInInfo], [PLA.TxOut], PLA.Value, PLA.Value, [PLA.DCert], ([(PLA.StakingCredential, Integer)], PLA.POSIXTimeRange, [PLA.PubKeyHash], [(PLA.DatumHash, PLA.Datum)], PLA.TxId))
into :: TxInfo
-> ([TxInInfo], [TxOut], Value, Value, [DCert],
([(StakingCredential, Integer)], POSIXTimeRange, [PubKeyHash],
[(DatumHash, Datum)], TxId))
into (PLA.TxInfo [TxInInfo]
ins [TxOut]
outs Value
fee Value
mint [DCert]
dcert [(StakingCredential, Integer)]
wdrl POSIXTimeRange
validRange [PubKeyHash]
sigs [(DatumHash, Datum)]
dats TxId
tid) =
([TxInInfo]
ins, [TxOut]
outs, Value
fee, Value
mint, [DCert]
dcert, ([(StakingCredential, Integer)]
wdrl, POSIXTimeRange
validRange, [PubKeyHash]
sigs, [(DatumHash, Datum)]
dats, TxId
tid))
outOf ::
([PLA.TxInInfo], [PLA.TxOut], PLA.Value, PLA.Value, [PLA.DCert], ([(PLA.StakingCredential, Integer)], PLA.POSIXTimeRange, [PLA.PubKeyHash], [(PLA.DatumHash, PLA.Datum)], PLA.TxId)) ->
PLA.TxInfo
outOf :: ([TxInInfo], [TxOut], Value, Value, [DCert],
([(StakingCredential, Integer)], POSIXTimeRange, [PubKeyHash],
[(DatumHash, Datum)], TxId))
-> TxInfo
outOf ([TxInInfo]
ins, [TxOut]
outs, Value
fee, Value
mint, [DCert]
dcert, ([(StakingCredential, Integer)]
wdrl, POSIXTimeRange
validRange, [PubKeyHash]
sigs, [(DatumHash, Datum)]
dats, TxId
tid)) =
[TxInInfo]
-> [TxOut]
-> Value
-> Value
-> [DCert]
-> [(StakingCredential, Integer)]
-> POSIXTimeRange
-> [PubKeyHash]
-> [(DatumHash, Datum)]
-> TxId
-> TxInfo
PLA.TxInfo [TxInInfo]
ins [TxOut]
outs Value
fee Value
mint [DCert]
dcert [(StakingCredential, Integer)]
wdrl POSIXTimeRange
validRange [PubKeyHash]
sigs [(DatumHash, Datum)]
dats TxId
tid
instance Arbitrary PLA.ScriptPurpose where
{-# INLINEABLE arbitrary #-}
arbitrary :: Gen ScriptPurpose
arbitrary =
[Gen ScriptPurpose] -> Gen ScriptPurpose
forall a. HasCallStack => [Gen a] -> Gen a
oneof
[ CurrencySymbol -> ScriptPurpose
PLA.Minting (CurrencySymbol -> ScriptPurpose)
-> Gen CurrencySymbol -> Gen ScriptPurpose
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen CurrencySymbol
forall a. Arbitrary a => Gen a
arbitrary
, TxOutRef -> ScriptPurpose
PLA.Spending (TxOutRef -> ScriptPurpose) -> Gen TxOutRef -> Gen ScriptPurpose
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen TxOutRef
forall a. Arbitrary a => Gen a
arbitrary
, StakingCredential -> ScriptPurpose
PLA.Rewarding (StakingCredential -> ScriptPurpose)
-> Gen StakingCredential -> Gen ScriptPurpose
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen StakingCredential
forall a. Arbitrary a => Gen a
arbitrary
, DCert -> ScriptPurpose
PLA.Certifying (DCert -> ScriptPurpose) -> Gen DCert -> Gen ScriptPurpose
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen DCert
forall a. Arbitrary a => Gen a
arbitrary
]
{-# INLINEABLE shrink #-}
shrink :: ScriptPurpose -> [ScriptPurpose]
shrink = \case
PLA.Minting CurrencySymbol
cs -> CurrencySymbol -> ScriptPurpose
PLA.Minting (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 TxOutRef
txo -> TxOutRef -> ScriptPurpose
PLA.Spending (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
txo
PLA.Rewarding StakingCredential
scred -> StakingCredential -> ScriptPurpose
PLA.Rewarding (StakingCredential -> ScriptPurpose)
-> [StakingCredential] -> [ScriptPurpose]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> StakingCredential -> [StakingCredential]
forall a. Arbitrary a => a -> [a]
shrink StakingCredential
scred
PLA.Certifying DCert
dcert -> DCert -> ScriptPurpose
PLA.Certifying (DCert -> ScriptPurpose) -> [DCert] -> [ScriptPurpose]
forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> DCert -> [DCert]
forall a. Arbitrary a => a -> [a]
shrink DCert
dcert
instance CoArbitrary PLA.ScriptPurpose where
{-# INLINEABLE coarbitrary #-}
coarbitrary :: forall b. ScriptPurpose -> Gen b -> Gen b
coarbitrary = \case
PLA.Minting CurrencySymbol
cs -> 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
. CurrencySymbol -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. CurrencySymbol -> Gen b -> Gen b
coarbitrary CurrencySymbol
cs
PLA.Spending TxOutRef
txo -> 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
. TxOutRef -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. TxOutRef -> Gen b -> Gen b
coarbitrary TxOutRef
txo
PLA.Rewarding StakingCredential
scred -> Int -> Gen b -> Gen b
forall n a. Integral n => n -> Gen a -> Gen a
variant (Int
2 :: Int) (Gen b -> Gen b) -> (Gen b -> Gen b) -> Gen b -> Gen b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StakingCredential -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. StakingCredential -> Gen b -> Gen b
coarbitrary StakingCredential
scred
PLA.Certifying DCert
dcert -> 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
. DCert -> Gen b -> Gen b
forall a b. CoArbitrary a => a -> Gen b -> Gen b
forall b. DCert -> Gen b -> Gen b
coarbitrary DCert
dcert
instance Function PLA.ScriptPurpose where
{-# INLINEABLE function #-}
function :: forall b. (ScriptPurpose -> b) -> ScriptPurpose :-> b
function = (ScriptPurpose
-> Either
CurrencySymbol (Either TxOutRef (Either StakingCredential DCert)))
-> (Either
CurrencySymbol (Either TxOutRef (Either StakingCredential DCert))
-> ScriptPurpose)
-> (ScriptPurpose -> b)
-> ScriptPurpose :-> b
forall b a c.
Function b =>
(a -> b) -> (b -> a) -> (a -> c) -> a :-> c
functionMap ScriptPurpose
-> Either
CurrencySymbol (Either TxOutRef (Either StakingCredential DCert))
into Either
CurrencySymbol (Either TxOutRef (Either StakingCredential DCert))
-> ScriptPurpose
outOf
where
into ::
PLA.ScriptPurpose ->
Either PLA.CurrencySymbol (Either PLA.TxOutRef (Either PLA.StakingCredential PLA.DCert))
into :: ScriptPurpose
-> Either
CurrencySymbol (Either TxOutRef (Either StakingCredential DCert))
into = \case
PLA.Minting CurrencySymbol
cs -> CurrencySymbol
-> Either
CurrencySymbol (Either TxOutRef (Either StakingCredential DCert))
forall a b. a -> Either a b
Left CurrencySymbol
cs
PLA.Spending TxOutRef
txo -> Either TxOutRef (Either StakingCredential DCert)
-> Either
CurrencySymbol (Either TxOutRef (Either StakingCredential DCert))
forall a b. b -> Either a b
Right (TxOutRef -> Either TxOutRef (Either StakingCredential DCert)
forall a b. a -> Either a b
Left TxOutRef
txo)
PLA.Rewarding StakingCredential
scred -> Either TxOutRef (Either StakingCredential DCert)
-> Either
CurrencySymbol (Either TxOutRef (Either StakingCredential DCert))
forall a b. b -> Either a b
Right (Either StakingCredential DCert
-> Either TxOutRef (Either StakingCredential DCert)
forall a b. b -> Either a b
Right (StakingCredential -> Either StakingCredential DCert
forall a b. a -> Either a b
Left StakingCredential
scred))
PLA.Certifying DCert
dcert -> Either TxOutRef (Either StakingCredential DCert)
-> Either
CurrencySymbol (Either TxOutRef (Either StakingCredential DCert))
forall a b. b -> Either a b
Right (Either StakingCredential DCert
-> Either TxOutRef (Either StakingCredential DCert)
forall a b. b -> Either a b
Right (DCert -> Either StakingCredential DCert
forall a b. b -> Either a b
Right DCert
dcert))
outOf ::
Either PLA.CurrencySymbol (Either PLA.TxOutRef (Either PLA.StakingCredential PLA.DCert)) ->
PLA.ScriptPurpose
outOf :: Either
CurrencySymbol (Either TxOutRef (Either StakingCredential DCert))
-> ScriptPurpose
outOf = \case
Left CurrencySymbol
cs -> CurrencySymbol -> ScriptPurpose
PLA.Minting CurrencySymbol
cs
Right (Left TxOutRef
txo) -> TxOutRef -> ScriptPurpose
PLA.Spending TxOutRef
txo
Right (Right (Left StakingCredential
scred)) -> StakingCredential -> ScriptPurpose
PLA.Rewarding StakingCredential
scred
Right (Right (Right DCert
dcert)) -> DCert -> ScriptPurpose
PLA.Certifying DCert
dcert